[pypy-svn] pypy default: raise a specific exception in this case, which makes it easier to catch the case of unsupported terminal

antocuni commits-noreply at bitbucket.org
Wed Mar 30 15:26:12 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r43015:8e3e376aa56b
Date: 2011-03-30 15:07 +0200
http://bitbucket.org/pypy/pypy/changeset/8e3e376aa56b/

Log:	raise a specific exception in this case, which makes it easier to
	catch the case of unsupported terminal

diff --git a/lib_pypy/pyrepl/unix_console.py b/lib_pypy/pyrepl/unix_console.py
--- a/lib_pypy/pyrepl/unix_console.py
+++ b/lib_pypy/pyrepl/unix_console.py
@@ -27,7 +27,10 @@
 from pyrepl.console import Console, Event
 from pyrepl import unix_eventqueue
 
-_error = (termios.error, curses.error)
+class InvalidTerminal(RuntimeError):
+    pass
+
+_error = (termios.error, curses.error, InvalidTerminal)
 
 # there are arguments for changing this to "refresh"
 SIGWINCH_EVENT = 'repaint'
@@ -38,7 +41,7 @@
 def _my_getstr(cap, optional=0):
     r = curses.tigetstr(cap)
     if not optional and r is None:
-        raise RuntimeError, \
+        raise InvalidTerminal, \
               "terminal doesn't have the required '%s' capability"%cap
     return r
 


More information about the Pypy-commit mailing list