[issue38638] Backtrace of exit phase of context managers

2020-11-26 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Traceback from __exit__ method is misleading

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38638] Backtrace of exit phase of context managers

2019-10-30 Thread Alexander Kurakin


New submission from Alexander Kurakin :

class CM:

def __init__(self):
pass

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
raise RuntimeError()

if __name__ == '__main__':
with CM() as cm:
print('Hello')


$ python3 cm.py 
Hello
Traceback (most recent call last):
  File "cm.py", line 14, in 
print('Hello')  # <--
  File "cm.py", line 10, in __exit__
raise RuntimeError()
RuntimeError


Is it correct that print presents in backtrace? Well it's the last line but...

Thanks.

--
components: Interpreter Core
messages: 355698
nosy: kuraga
priority: normal
severity: normal
status: open
title: Backtrace of exit phase of context managers
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com