[py-svn] py-trunk commit fe8516e8582a: introduce py.builtin._sysex as alias for the special exceptions, fixes #115

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Sep 14 16:18:56 CEST 2010


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
# Date 1284473570 -7200
# Node ID fe8516e8582a56daaefb50022b3c71d1ecc0ef86
# Parent  5ec349dff3b7ff77e842ce377e206799132697e1
introduce py.builtin._sysex as alias for the special exceptions, fixes #115

--- a/py/_code/_assertionold.py
+++ b/py/_code/_assertionold.py
@@ -3,7 +3,7 @@ import sys, inspect
 from compiler import parse, ast, pycodegen
 from py._code.assertion import BuiltinAssertionError, _format_explanation
 
-passthroughex = (KeyboardInterrupt, SystemExit, MemoryError)
+passthroughex = py.builtin._sysex
 
 class Failure:
     def __init__(self, node):

--- a/py/__init__.py
+++ b/py/__init__.py
@@ -111,6 +111,7 @@ py.apipkg.initpkg(__name__, dict(
         'frozenset'      : '._builtin:frozenset',
         'BaseException'  : '._builtin:BaseException',
         'GeneratorExit'  : '._builtin:GeneratorExit',
+        '_sysex'         : '._builtin:_sysex',
         'print_'         : '._builtin:print_',
         '_reraise'       : '._builtin:_reraise',
         '_tryimport'     : '._builtin:_tryimport',

--- a/py/_code/code.py
+++ b/py/_code/code.py
@@ -189,7 +189,7 @@ class TracebackEntry(object):
         """
         try:
             return self.frame.eval("__tracebackhide__")
-        except (SystemExit, KeyboardInterrupt):
+        except py.builtin._sysex:
             raise
         except:
             return False

--- a/py/_io/terminalwriter.py
+++ b/py/_io/terminalwriter.py
@@ -26,7 +26,7 @@ def _getdimensions():
 def get_terminal_width():
     try:
         height, width = _getdimensions()
-    except (SystemExit, KeyboardInterrupt):
+    except py.builtin._sysex:
         raise
     except:
         # FALLBACK

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ Changes between 1.3.3 and 1.3.4
 - fix issue111: improve install documentation for windows
 - fix issue116: --doctestmodules works in the presence of __init__.py files as well
 - fix issue118: new --tb=native option for presenting cpython-standard exceptions
+- fix issue115: introduce py.builtin._sysex for system level exceptions we should thread different
 
 Changes between 1.3.2 and 1.3.3
 ==================================================

--- a/py/_builtin.py
+++ b/py/_builtin.py
@@ -87,6 +87,8 @@ except NameError:
         pass
     GeneratorExit.__module__ = 'exceptions'
 
+_sysex = (KeyboardInterrupt, SystemExit, MemoryError, GeneratorExit)
+
 if sys.version_info >= (3, 0):
     exec ("print_ = print ; exec_=exec")
     import builtins

--- a/py/_test/collect.py
+++ b/py/_test/collect.py
@@ -102,7 +102,7 @@ class Node(object):
             return getattr(self, attrname)
         try:
             res = function()
-        except (KeyboardInterrupt, SystemExit):
+        except py.builtin._sysex:
             raise
         except:
             failure = py.std.sys.exc_info()

--- a/py/_io/saferepr.py
+++ b/py/_io/saferepr.py
@@ -5,8 +5,6 @@ builtin_repr = repr
 
 reprlib = py.builtin._tryimport('repr', 'reprlib')
 
-sysex = (KeyboardInterrupt, MemoryError, SystemExit)
-
 class SafeRepr(reprlib.Repr):
     """ subclass of repr.Repr that limits the resulting size of repr()
         and includes information on exceptions raised during the call.
@@ -21,7 +19,7 @@ class SafeRepr(reprlib.Repr):
         try:
             # Try the vanilla repr and make sure that the result is a string
             s = call(x, *args)
-        except sysex:
+        except py.builtin._sysex:
             raise
         except:
             cls, e, tb = sys.exc_info()

--- a/py/_code/assertion.py
+++ b/py/_code/assertion.py
@@ -44,7 +44,7 @@ class AssertionError(BuiltinAssertionErr
         if args:
             try:
                 self.msg = str(args[0])
-            except (KeyboardInterrupt, SystemExit):
+            except py.builtin._sysex:
                 raise
             except:
                 self.msg = "<[broken __repr__] %s at %0xd>" %(

--- a/py/_code/source.py
+++ b/py/_code/source.py
@@ -276,7 +276,7 @@ def getfslineno(obj):
 def findsource(obj):
     try:
         sourcelines, lineno = py.std.inspect.findsource(obj)
-    except (KeyboardInterrupt, SystemExit):
+    except py.builtin._sysex:
         raise
     except:
         return None, None



More information about the pytest-commit mailing list