gh-88760: fix (Async)ExitStack handling of __context__ by belm0 · Pull Request #27089 · python/cpython

Conversation

@belm0 belm0 marked this pull request as draft

July 12, 2021 01:08

@belm0 belm0 mentioned this pull request

Jul 12, 2021
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.

TODO: unit tests

belm0

Comment on lines -534 to +537

@belm0 belm0 marked this pull request as ready for review

July 12, 2021 10:33

belm0 added a commit to belm0/cpython that referenced this pull request

Oct 5, 2021
…ngh-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..
(cherry picked from commit e6d1aa1)

Co-authored-by: John Belmonte <john@neggie.net>

belm0 added a commit to belm0/cpython that referenced this pull request

Oct 5, 2021
…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..
(cherry picked from commit e6d1aa1)

Co-authored-by: John Belmonte <john@neggie.net>

@belm0 belm0 deleted the exit_stack_context branch

October 5, 2021 06:11

miss-islington pushed a commit that referenced this pull request

Oct 5, 2021
) (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 e6d1aa1)

Co-authored-by: John Belmonte <john@neggie.net>

Automerge-Triggered-By: GH:njsmith

miss-islington pushed a commit that referenced this pull request

Oct 5, 2021
…) (GH-28731)

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

Co-authored-by: John Belmonte <john@neggie.net>

Automerge-Triggered-By: GH:njsmith

@terryjreedy terryjreedy changed the title bpo-44594: fix (Async)ExitStack handling of __context__ gh-88760: fix (Async)ExitStack handling of __context__

Feb 18, 2025