]> granicus.if.org Git - python/commitdiff
#1119331: ncurses will just call exit() if the terminal name isn't found.
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 23 Feb 2008 15:49:35 +0000 (15:49 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 23 Feb 2008 15:49:35 +0000 (15:49 +0000)
Call setupterm() first so that we get a Python exception instead of just existing.

Lib/curses/__init__.py

index aba540b70ebaeb64d88cf640cd5567614ed9125e..c3f2f25c30657fb07ea8cf7855b9818e16252c22 100644 (file)
@@ -14,6 +14,7 @@ __revision__ = "$Id$"
 
 from _curses import *
 from curses.wrapper import wrapper
+import os as _os
 
 # Some constants, most notably the ACS_* ones, are only added to the C
 # _curses module's dictionary after initscr() is called.  (Some
@@ -25,6 +26,9 @@ from curses.wrapper import wrapper
 
 def initscr():
     import _curses, curses
+    # we call setupterm() here because it raises an error
+    # instead of calling exit() in error cases.
+    setupterm(term=_os.environ.get("TERM", "unknown"))
     stdscr = _curses.initscr()
     for key, value in _curses.__dict__.items():
         if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):