Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r59179:83685d099042
Date: 2012-12-01 11:30 -0800
http://bitbucket.org/pypy/pypy/changeset/83685d099042/

Log:    workaround the fact that sys.exc_info doesn't work inside
        appleveldefs

diff --git a/pypy/module/atexit/app_atexit.py b/pypy/module/atexit/app_atexit.py
--- a/pypy/module/atexit/app_atexit.py
+++ b/pypy/module/atexit/app_atexit.py
@@ -27,10 +27,11 @@
             func(*args, **kwargs)
         except BaseException as e:
             if not isinstance(e, SystemExit):
-                import sys
                 import traceback
-                last_type, last_exc, last_tb = sys.exc_info()
-                traceback.print_exception(last_type, last_exc, last_tb)
+                # obscure: we can't use sys.exc_info() here because this
+                # function is an appleveldef which marks its frame as
+                # hidden
+                traceback.print_exception(type(e), e, e.__traceback__)
 
     clear()
 
diff --git a/pypy/module/atexit/test/test_atexit.py 
b/pypy/module/atexit/test/test_atexit.py
--- a/pypy/module/atexit/test/test_atexit.py
+++ b/pypy/module/atexit/test/test_atexit.py
@@ -18,3 +18,8 @@
         finally:
             sys.stdout = stdout
             sys.stderr = stderr
+
+    def test_badargs(self):
+        import atexit
+        atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
+        raises(TypeError, atexit._run_exitfuncs)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to