[pypy-commit] pypy release-2.1.x: Test for the "except:" path. Tests that the exception class is only
arigo
noreply at buildbot.pypy.org
Sat Jul 20 14:10:20 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: release-2.1.x
Changeset: r65514:02f3dda99f30
Date: 2013-07-19 20:51 +0200
http://bitbucket.org/pypy/pypy/changeset/02f3dda99f30/
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]
More information about the pypy-commit
mailing list