Search code examples
pythonncursescurses

error with curses tigetstr in Python 2.6.6


After I upgraded Ubuntu my Python was changed to 2.6.6 and my app.py stopped working when calling

sys.stdout.write(curses.tigetstr('civis'))

it writes:

Traceback (most recent call last):
  File "app.py", line 60, in <module>
    sys.stdout.write(curses.tigetstr('civis'))
TypeError: argument 1 must be string or read-only character buffer, not None

Should I change my code for newer version of Python?


Solution

  • Reading the documentation:

    curses.tigetstr(capname)

    Return the value of the string capability corresponding to the terminfo capability name capname. None is returned if capname is not a string capability, or is canceled or absent from the terminal description.

    I take it the problem might be with the terminal description. I am running python 2.7.2 on Ubuntu 11.10 and the following code does not raise any exception:

    import sys
    import curses
    curses.setupterm()
    sys.stdout.write(curses.tigetstr('civis'))
    

    Does that work for you? If yes, your problem might have to do with some terminal setup prior to the call to curses.tigestr...