This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Backtrace of exit phase of context managers
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: Traceback from __exit__ method is misleading
View: 25538
Assigned To: Nosy List: kuraga
Priority: normal Keywords:

Created on 2019-10-30 09:21 by kuraga, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (1)
msg355698 - (view) Author: Alexander Kurakin (kuraga) Date: 2019-10-30 09:21
class CM:

    def __init__(self):

    def __enter__(self):
        return self

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

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

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

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

Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82819
2020-11-26 23:23:08iritkatrielsetstatus: open -> closed
superseder: Traceback from __exit__ method is misleading
resolution: duplicate
stage: resolved
2019-10-30 09:21:06kuragacreate