]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.10] bpo-44594: fix (Async)ExitStack handling of __context__ (gh-27089) (GH-28730)
authorJohn Belmonte <john@neggie.net>
Tue, 5 Oct 2021 06:21:34 +0000 (15:21 +0900)
committerGitHub <noreply@github.com>
Tue, 5 Oct 2021 06:21:34 +0000 (23:21 -0700)
commit872b1e537e96d0dc4ff37c738031940b5d271366
tree9eb4a7d575fda3c330123a50f9fde515bb53fc50
parent1e328afb04aa5dbb396e105b1ef65a79eb394dde
[3.10] bpo-44594: fix (Async)ExitStack handling of __context__ (gh-27089) (GH-28730)

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..
(cherry picked from commit e6d1aa1ac65b6908fdea2c70ec3aa8c4f1dffcb5)

Co-authored-by: John Belmonte <john@neggie.net>
Automerge-Triggered-By: GH:njsmith
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]