[Python-checkins] r60989 - python/trunk/Lib/curses/__init__.py

andrew.kuchling python-checkins at python.org
Sat Feb 23 16:49:36 CET 2008


Author: andrew.kuchling
Date: Sat Feb 23 16:49:35 2008
New Revision: 60989

Modified:
   python/trunk/Lib/curses/__init__.py
Log:
#1119331: ncurses will just call exit() if the terminal name isn't found.
Call setupterm() first so that we get a Python exception instead of just existing.

Modified: python/trunk/Lib/curses/__init__.py
==============================================================================
--- python/trunk/Lib/curses/__init__.py	(original)
+++ python/trunk/Lib/curses/__init__.py	Sat Feb 23 16:49:35 2008
@@ -14,6 +14,7 @@
 
 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 @@
 
 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'):


More information about the Python-checkins mailing list