Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r65485:d2ffe8aaa387 Date: 2013-07-19 20:51 +0200 http://bitbucket.org/pypy/pypy/changeset/d2ffe8aaa387/
Log: Test for the "except:" path. Tests that the exception class is only instantiated once, and fix. diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py --- a/lib_pypy/greenlet.py +++ b/lib_pypy/greenlet.py @@ -1,3 +1,4 @@ +import sys import _continuation __version__ = "0.4.0" @@ -84,8 +85,8 @@ methodname = 'switch' baseargs = (((e,), {}),) except: - pass - convert_greenletexit = False + baseargs = sys.exc_info()[:2] + baseargs[2:] + convert_greenletexit = False # try: unbound_method = getattr(_continulet, methodname) diff --git a/pypy/module/test_lib_pypy/test_greenlet.py b/pypy/module/test_lib_pypy/test_greenlet.py --- a/pypy/module/test_lib_pypy/test_greenlet.py +++ b/pypy/module/test_lib_pypy/test_greenlet.py @@ -360,3 +360,21 @@ e = greenlet.GreenletExit() x = g.throw(e) assert x is e + + def test_throw_exception_already_finished(self): + import greenlet + def f(): + pass + g = greenlet.greenlet(f) + g.switch() + seen = [] + class MyException(Exception): + def __init__(self): + seen.append(1) + try: + g.throw(MyException) + except MyException: + pass + else: + raise AssertionError("no exception??") + assert seen == [1] _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit