New submission from Alexander Kurakin <[email protected]>:
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 <module>
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 <[email protected]>
<https://bugs.python.org/issue38638>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com