Commits

Philip Jenvey committed 83685d0

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

  • Participants
  • Parent commits 1fae8d2
  • Branches py3k

Comments (0)

Files changed (2)

pypy/module/atexit/app_atexit.py

             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()
 

pypy/module/atexit/test/test_atexit.py

         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)