-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed as not planned
Closed as not planned
Copy link
Labels
3.11only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug description:
class CM:
def __init__(self, fail=False):
self.fail = fail
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
assert not self.fail
with (
CM(fail=True) as a,
CM() as b,
):
pass
and the traceback should tell us where this failed, right?
Traceback (most recent call last):
File "repro.py", line 12, in <module>
with (
File "repro.py", line 9, in __exit__
assert not self.fail
AssertionError
In more realistic use-cases1, it would be very helpful if the traceback pointed to line 13
CM(fail=True) as a,
rather than line 12
with (
.
I've tested this on Python 3.11, and searching the changelogs for 3.12/13/14 didn't show any related changes.
Footnotes
-
in the case that motivated this issue, I have eleven context managers in one
async with
statement, which I admit may be excessive - it's certainly motivating. ↩
yang
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error