introduce py.builtin._sysex as alias for the special exceptions, fixes #115
--HG-- branch : trunk
This commit is contained in:
parent
04b3b9a3da
commit
b81e48507c
|
@ -4,6 +4,7 @@ Changes between 1.3.3 and 1.3.4
|
||||||
- fix issue111: improve install documentation for windows
|
- fix issue111: improve install documentation for windows
|
||||||
- fix issue116: --doctestmodules works in the presence of __init__.py files as well
|
- 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 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
|
Changes between 1.3.2 and 1.3.3
|
||||||
==================================================
|
==================================================
|
||||||
|
|
|
@ -111,6 +111,7 @@ py.apipkg.initpkg(__name__, dict(
|
||||||
'frozenset' : '._builtin:frozenset',
|
'frozenset' : '._builtin:frozenset',
|
||||||
'BaseException' : '._builtin:BaseException',
|
'BaseException' : '._builtin:BaseException',
|
||||||
'GeneratorExit' : '._builtin:GeneratorExit',
|
'GeneratorExit' : '._builtin:GeneratorExit',
|
||||||
|
'_sysex' : '._builtin:_sysex',
|
||||||
'print_' : '._builtin:print_',
|
'print_' : '._builtin:print_',
|
||||||
'_reraise' : '._builtin:_reraise',
|
'_reraise' : '._builtin:_reraise',
|
||||||
'_tryimport' : '._builtin:_tryimport',
|
'_tryimport' : '._builtin:_tryimport',
|
||||||
|
|
|
@ -87,6 +87,8 @@ except NameError:
|
||||||
pass
|
pass
|
||||||
GeneratorExit.__module__ = 'exceptions'
|
GeneratorExit.__module__ = 'exceptions'
|
||||||
|
|
||||||
|
_sysex = (KeyboardInterrupt, SystemExit, MemoryError, GeneratorExit)
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
exec ("print_ = print ; exec_=exec")
|
exec ("print_ = print ; exec_=exec")
|
||||||
import builtins
|
import builtins
|
||||||
|
|
|
@ -3,7 +3,7 @@ import sys, inspect
|
||||||
from compiler import parse, ast, pycodegen
|
from compiler import parse, ast, pycodegen
|
||||||
from py._code.assertion import BuiltinAssertionError, _format_explanation
|
from py._code.assertion import BuiltinAssertionError, _format_explanation
|
||||||
|
|
||||||
passthroughex = (KeyboardInterrupt, SystemExit, MemoryError)
|
passthroughex = py.builtin._sysex
|
||||||
|
|
||||||
class Failure:
|
class Failure:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
|
|
|
@ -44,7 +44,7 @@ class AssertionError(BuiltinAssertionError):
|
||||||
if args:
|
if args:
|
||||||
try:
|
try:
|
||||||
self.msg = str(args[0])
|
self.msg = str(args[0])
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
self.msg = "<[broken __repr__] %s at %0xd>" %(
|
self.msg = "<[broken __repr__] %s at %0xd>" %(
|
||||||
|
|
|
@ -189,7 +189,7 @@ class TracebackEntry(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.frame.eval("__tracebackhide__")
|
return self.frame.eval("__tracebackhide__")
|
||||||
except (SystemExit, KeyboardInterrupt):
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -276,7 +276,7 @@ def getfslineno(obj):
|
||||||
def findsource(obj):
|
def findsource(obj):
|
||||||
try:
|
try:
|
||||||
sourcelines, lineno = py.std.inspect.findsource(obj)
|
sourcelines, lineno = py.std.inspect.findsource(obj)
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
|
@ -5,8 +5,6 @@ builtin_repr = repr
|
||||||
|
|
||||||
reprlib = py.builtin._tryimport('repr', 'reprlib')
|
reprlib = py.builtin._tryimport('repr', 'reprlib')
|
||||||
|
|
||||||
sysex = (KeyboardInterrupt, MemoryError, SystemExit)
|
|
||||||
|
|
||||||
class SafeRepr(reprlib.Repr):
|
class SafeRepr(reprlib.Repr):
|
||||||
""" subclass of repr.Repr that limits the resulting size of repr()
|
""" subclass of repr.Repr that limits the resulting size of repr()
|
||||||
and includes information on exceptions raised during the call.
|
and includes information on exceptions raised during the call.
|
||||||
|
@ -21,7 +19,7 @@ class SafeRepr(reprlib.Repr):
|
||||||
try:
|
try:
|
||||||
# Try the vanilla repr and make sure that the result is a string
|
# Try the vanilla repr and make sure that the result is a string
|
||||||
s = call(x, *args)
|
s = call(x, *args)
|
||||||
except sysex:
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
cls, e, tb = sys.exc_info()
|
cls, e, tb = sys.exc_info()
|
||||||
|
|
|
@ -26,7 +26,7 @@ def _getdimensions():
|
||||||
def get_terminal_width():
|
def get_terminal_width():
|
||||||
try:
|
try:
|
||||||
height, width = _getdimensions()
|
height, width = _getdimensions()
|
||||||
except (SystemExit, KeyboardInterrupt):
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
# FALLBACK
|
# FALLBACK
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Node(object):
|
||||||
return getattr(self, attrname)
|
return getattr(self, attrname)
|
||||||
try:
|
try:
|
||||||
res = function()
|
res = function()
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except py.builtin._sysex:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
failure = py.std.sys.exc_info()
|
failure = py.std.sys.exc_info()
|
||||||
|
|
Loading…
Reference in New Issue