Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backtrace of exit phase of context managers #82819

Closed
kuraga mannequin opened this issue Oct 30, 2019 · 1 comment
Closed

Backtrace of exit phase of context managers #82819

kuraga mannequin opened this issue Oct 30, 2019 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@kuraga
Copy link
Mannequin

kuraga mannequin commented Oct 30, 2019

BPO 38638
Nosy @kuraga
Superseder
  • bpo-25538: Traceback from exit method is misleading
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-11-26.23:23:08.176>
    created_at = <Date 2019-10-30.09:21:06.499>
    labels = ['interpreter-core', 'type-bug']
    title = 'Backtrace of exit phase of context managers'
    updated_at = <Date 2020-11-26.23:23:08.175>
    user = 'https://github.com/kuraga'

    bugs.python.org fields:

    activity = <Date 2020-11-26.23:23:08.175>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-26.23:23:08.176>
    closer = 'iritkatriel'
    components = ['Interpreter Core']
    creation = <Date 2019-10-30.09:21:06.499>
    creator = 'kuraga'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38638
    keywords = []
    message_count = 1.0
    messages = ['355698']
    nosy_count = 1.0
    nosy_names = ['kuraga']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '25538'
    type = 'behavior'
    url = 'https://bugs.python.org/issue38638'
    versions = ['Python 3.6']

    @kuraga
    Copy link
    Mannequin Author

    kuraga mannequin commented Oct 30, 2019

    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.

    @kuraga kuraga mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Oct 30, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant