Martin Panter added the comment: Here is a patch for Python 3. The re-raise behaviour reported by Antoine is already tested in test_raise.TestRaise.test_except_reraise().
My patch also clarifies some details about how __context__ is set: * Context is the exception being handled, not necessarily the last exception * “With” statements can influence context * Re-raising does not set context; must be new exception object * Add test case when context is not the last exception I’m not so experienced with Python 2’s exception handling, so I haven’t got a patch for that. I suspect there is some shared “last exception” context. I wonder how it interacts with generators, multi-threading, __del__() and other callbacks, etc. ---------- keywords: +patch stage: -> patch review versions: +Python 3.5, Python 3.6 Added file: http://bugs.python.org/file40053/raise-scope-py3.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23556> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com