[pypy-svn] r20633 - pypy/dist/pypy
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 4 11:51:36 CET 2005
Author: arigo
Date: Sun Dec 4 11:51:34 2005
New Revision: 20633
Modified:
pypy/dist/pypy/conftest.py
Log:
Hacked on conftest.py until it again does the Right Thing with interp- and
app-level KeyboardInterrupt.
Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py (original)
+++ pypy/dist/pypy/conftest.py Sun Dec 4 11:51:34 2005
@@ -62,16 +62,8 @@
kwds.setdefault('usemodules', option.usemodules)
kwds.setdefault('compiler', option.compiler)
space = Space(**kwds)
- except KeyboardInterrupt:
- raise
- except OperationError, e:
- # we cannot easily convert w_KeyboardInterrupt to
- # KeyboardInterrupt so we have to jump through hoops
- try:
- if e.w_type.name == 'KeyboardInterrupt':
- raise KeyboardInterrupt
- except AttributeError:
- pass
+ except OperationError, e:
+ check_keyboard_interrupt(e)
if option.verbose:
import traceback
traceback.print_exc()
@@ -87,6 +79,19 @@
space.eq_w = appsupport.eq_w.__get__(space)
return space
+class OpErrKeyboardInterrupt(KeyboardInterrupt):
+ pass
+
+def check_keyboard_interrupt(e):
+ # we cannot easily convert w_KeyboardInterrupt to KeyboardInterrupt
+ # in general without a space -- here is an approximation
+ try:
+ if e.w_type.name == 'KeyboardInterrupt':
+ tb = sys.exc_info()[2]
+ raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
+ except AttributeError:
+ pass
+
#
# Interfacing/Integrating with py.test's collection process
#
@@ -147,8 +152,9 @@
try:
target(*args)
except OperationError, e:
- if e.match(space, space.w_KeyboardInterrupt):
- raise KeyboardInterrupt
+ if e.match(space, space.w_KeyboardInterrupt):
+ tb = sys.exc_info()[2]
+ raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
appexcinfo = appsupport.AppExceptionInfo(space, e)
if appexcinfo.traceback:
raise self.Failed(excinfo=appsupport.AppExceptionInfo(space, e))
@@ -159,11 +165,15 @@
class IntTestFunction(PyPyTestFunction):
def execute(self, target, *args):
co = target.func_code
- if 'space' in co.co_varnames[:co.co_argcount]:
- space = gettestobjspace()
- target(space, *args)
- else:
- target(*args)
+ try:
+ if 'space' in co.co_varnames[:co.co_argcount]:
+ space = gettestobjspace()
+ target(space, *args)
+ else:
+ target(*args)
+ except OperationError, e:
+ check_keyboard_interrupt(e)
+ raise
if 'pygame' in sys.modules:
global _pygame_warned
if not _pygame_warned:
More information about the Pypy-commit
mailing list