FAQ
I just upgraded from Python 1.5.2 to 2.0, and curses doesn't seem to
work anymore. I run cplay (an mp3 player frontend in Python), and even
after explicitly building and installing the _curses module (initially
import curses failed because the curses module itself tried to import
_curses), I now get the following error:

max at charmaine:~% /usr/local/bin/python `which cplay`
Traceback (most recent call last):
File "/usr/local/bin/cplay", line 1173, in main
app.setup()
File "/usr/local/bin/cplay", line 1028, in setup
self.win_root = RootWindow(None)
File "/usr/local/bin/cplay", line 293, in __init__
self.win_progress = ProgressWindow(self)
File "/usr/local/bin/cplay", line 193, in __init__
Window.__init__(self, parent)
File "/usr/local/bin/cplay", line 105, in __init__
self.resize()
File "/usr/local/bin/cplay", line 136, in resize
self.w = self.newwin()
File "/usr/local/bin/cplay", line 197, in newwin
return curses.newwin(1, self.parent.cols, self.parent.rows-2, 0)
error: curses function returned NULL

In trying to see what's going on with curses, I tried:

max at charmaine:~% python
Python 2.0 (#3, Nov 5 2000, 11:15:21)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
import curses
curses.initscr()
at which point the screen blanks and I get

<curses window object at 0x818b4d8>
>>>

where all import is ignored except keyboard interrupts (which is in
contrast to doing the same thing with Python 1.5.2, where curses mode is
obviously interfering with the Python interpreter, but you can still
issue commands).

Any idea what's going on here?

--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ What do women want?
\__/ Sigmund Freud
Alcyone Systems' CatCam / http://www.catcam.com/
What do your pets do all day while you're at work? Find out.

Search Discussions

  • Alex at Nov 6, 2000 at 2:02 am

    File "/usr/local/bin/cplay", line 197, in newwin
    return curses.newwin(1, self.parent.cols, self.parent.rows-2, 0)
    error: curses function returned NULL
    Perhaps the size of the window you're requesting is inappropriate;
    either too big, or negative. That is the only time I've seen this
    error, that I recall.
    import curses
    curses.initscr()
    at which point the screen blanks and I get

    <curses window object at 0x818b4d8>
    where all import is ignored except keyboard interrupts (which is in
    contrast to doing the same thing with Python 1.5.2, where curses mode
    is obviously interfering with the Python interpreter, but you can
    still issue commands).
    I didn't start playing with curses until after I moved to 2.0, but I
    started with Andrew Kuchling's HOWTO on curses. It gives a framework
    for debugging curses programs that I find very convenient.

    http://python.org/doc/howto/curses/curses.html

    HTH.
    Alex.

    --
    Speak softly but carry a big carrot.
  • Andrew Kuchling at Nov 6, 2000 at 3:08 pm

    Erik Max Francis <max at alcyone.com> writes:
    File "/usr/local/bin/cplay", line 197, in newwin
    return curses.newwin(1, self.parent.cols, self.parent.rows-2, 0)
    error: curses function returned NULL
    What are the values of self.parent.cols and self.parent.rows? Perhaps
    they're bogus values.
    max at charmaine:~% python
    Python 2.0 (#3, Nov 5 2000, 11:15:21)
    [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
    Type "copyright", "credits" or "license" for more information.
    import curses
    curses.initscr()
    at which point the screen blanks and I get
    <curses window object at 0x818b4d8>
    This behaviour is what I'd expect; curses has cleared the screen and
    changed the console parameters to turn off keyboard echo. Typing
    curses.endwin() blindly should fix your terminal again.

    --amk
  • Ulf Betlehem at Nov 10, 2000 at 2:52 pm

    Erik Max Francis <max at alcyone.com> writes:

    max at charmaine:~% /usr/local/bin/python `which cplay`
    Traceback (most recent call last):
    File "/usr/local/bin/cplay", line 1173, in main
    app.setup()
    File "/usr/local/bin/cplay", line 1028, in setup
    self.win_root = RootWindow(None)
    File "/usr/local/bin/cplay", line 293, in __init__
    self.win_progress = ProgressWindow(self)
    File "/usr/local/bin/cplay", line 193, in __init__
    Window.__init__(self, parent)
    File "/usr/local/bin/cplay", line 105, in __init__
    self.resize()
    File "/usr/local/bin/cplay", line 136, in resize
    self.w = self.newwin()
    File "/usr/local/bin/cplay", line 197, in newwin
    return curses.newwin(1, self.parent.cols, self.parent.rows-2, 0)
    error: curses function returned NULL
    Based on the line numbers, I suspect that your version of
    cplay is rather old. Newer versions have been tested with
    Python 2.0 and seem to work just fine:

    http://www.tf.hut.fi/~flu/cplay/

    Most probably, what happens is that cplay thinks you are using
    pyncurses and tries to compensate for differences in religious
    beliefs. That is, pyncurses thinks getmaxyx() should actually
    return maximum coordinates instead of width and height. :>

    --
    flu
  • Erik Max Francis at Nov 10, 2000 at 6:28 pm

    Ulf Betlehem wrote:

    Based on the line numbers, I suspect that your version of
    cplay is rather old. Newer versions have been tested with
    Python 2.0 and seem to work just fine:

    http://www.tf.hut.fi/~flu/cplay/
    Well, that would certainly explain it. And here I was, presuming that
    cplay was unsupported.

    1.40 definitely works fine with Python 2.0. Thanks.

    In other porting news, I had written quite a few (relatively involved)
    Python scripts to do various sundry activities (an interface library to
    a talker as well as numerous programs that acted as bots which served as
    chess game arbiters, dealt cards, etc.); the only change I had to make
    in porting to Python 2.0 was changing the call to socket.connect to use
    a tuple, which I had already known about from reading summaries of the
    changes. Pretty painless.

    --
    Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
    __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
    / \ All men think all men mortal, save themselves.
    \__/ Edmund Young
    Computer science / http://www.alcyone.com/max/reference/compsci/
    A computer science reference.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 5, '00 at 7:32p
activeNov 10, '00 at 6:28p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase