Commits

Armin Rigo committed 1c74480

Fix the second test.

Comments (0)

Files changed (1)

lib_pypy/greenlet.py

 
     def __switch(target, methodname, *baseargs):
         current = getcurrent()
+        convert_greenletexit = True
         #
         while not (target.__main or _continulet.is_pending(target)):
             # inlined __nonzero__ ^^^ in case it's overridden
             # up the 'parent' explicitly.  Good enough, because a Ctrl-C
             # will show that the program is caught in this loop here.)
             target = target.parent
+            # convert a "raise GreenletExit" into "return GreenletExit"
+            if methodname == 'throw' and convert_greenletexit:
+                try:
+                    raise baseargs[0], baseargs[1]
+                except GreenletExit, e:
+                    methodname = 'switch'
+                    baseargs = (((e,), {}),)
+                except:
+                    pass
+                convert_greenletexit = False
         #
         try:
             unbound_method = getattr(_continulet, methodname)