]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-44594: fix (Async)ExitStack handling of __context__ (gh-27089)
authorJohn Belmonte <john@neggie.net>
Mon, 4 Oct 2021 06:49:55 +0000 (15:49 +0900)
committerGitHub <noreply@github.com>
Mon, 4 Oct 2021 06:49:55 +0000 (23:49 -0700)
commite6d1aa1ac65b6908fdea2c70ec3aa8c4f1dffcb5
tree317af9f26a2c7233a73b2fadccd23f91b5f254c5
parenta25dcaefb7c4eb0767a112cd31fe0b055f168844
bpo-44594: fix (Async)ExitStack handling of __context__ (gh-27089)

* bpo-44594: fix (Async)ExitStack handling of __context__

Make enter_context(foo()) / enter_async_context(foo()) equivalent to
`[async] with foo()` regarding __context__ when an exception is raised.

Previously exceptions would be caught and re-raised with the wrong
context when explicitly overriding __context__ with None.
Lib/contextlib.py
Lib/test/test_contextlib.py
Lib/test/test_contextlib_async.py
Misc/NEWS.d/next/Library/2021-07-12-10-32-48.bpo-44594.eEa5zi.rst [new file with mode: 0644]