Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid creating AttributeError exceptions in the debugger #80731

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

Closed
blueyed mannequin opened this issue Apr 7, 2019 · 5 comments
Closed

Avoid creating AttributeError exceptions in the debugger #80731

blueyed mannequin opened this issue Apr 7, 2019 · 5 comments
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir

Comments

@blueyed
Copy link
Mannequin

blueyed mannequin commented Apr 7, 2019

BPO 36550
Nosy @blueyed, @iritkatriel
PRs
  • bpo-36550: pdb/cmd: avoid creating exceptions #4666
  • 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 = None
    created_at = <Date 2019-04-07.19:15:47.340>
    labels = ['library', '3.9', '3.10', '3.11']
    title = 'Avoid creating AttributeError exceptions in the debugger'
    updated_at = <Date 2021-09-07.13:07:17.500>
    user = 'https://github.com/blueyed'

    bugs.python.org fields:

    activity = <Date 2021-09-07.13:07:17.500>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-04-07.19:15:47.340>
    creator = 'blueyed'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36550
    keywords = ['patch']
    message_count = 4.0
    messages = ['339583', '401237', '401253', '401260']
    nosy_count = 2.0
    nosy_names = ['blueyed', 'iritkatriel']
    pr_nums = ['4666']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36550'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Apr 7, 2019

    pdb should try (hard) to avoid creating unnecessary exceptions, e.g. AttributeError when looking up commands, since this will show up in exception chains then (as "'Pdb' object has no attribute 'do_foo'").

    See #4666 for an older PR in this regard.

    My use case is to display the traceback for exceptions caused within/via Pdb.default(), to see more context when running code from pdb's prompt directly, where currently it would only display the exception itself.

    @blueyed blueyed mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir labels Apr 7, 2019
    @iritkatriel
    Copy link
    Member

    Closing as the bug is not clear and the OP is not responding to requests on the PR to clarify it. Please create a new issue if you are still seeing a problem.

    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Sep 7, 2021

    Given code like the following the try/except handling of Pdb (via Cmd.onecmd, see #4666) will mess with sys.exc_info(), which could be avoided:

    try:
        raise ValueError()
    except Exception as exc:
        e = exc
        __import__('pdb').set_trace()
    
    % ./python t_issue36550.py
    --Return--
    > …/t_issue36550.py(5)<module>()->None
    -> __import__('pdb').set_trace()
    (Pdb) import sys; sys.exc_info()
    (<class 'AttributeError'>, AttributeError("'Pdb' object has no attribute 'do_import'"), <traceback object at 0x7f92d2782500>)
    

    The initial / better motivation was described in the original issue: with pdb++/pdbpp I want to display tracebacks/errors with errors that might occur via Pdb's prompt, where this then showed up as interfering with it.

    (Sorry for not responding on #4666 earlier, but I think it is only part of this issue, and therefore it should not get closed, and also creating a new one instead does not sound useful to me, so please consider to re-open it instead.)

    @blueyed blueyed mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.10 only security fixes 3.11 only security fixes labels Sep 7, 2021
    @iritkatriel
    Copy link
    Member

    Reopened.

    @iritkatriel iritkatriel removed 3.7 (EOL) end of life 3.8 (EOL) end of life labels Sep 7, 2021
    @iritkatriel iritkatriel reopened this Sep 7, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @serhiy-storchaka serhiy-storchaka added 3.12 only security fixes 3.13 bugs and security fixes and removed 3.11 only security fixes 3.10 only security fixes 3.9 only security fixes 3.12 only security fixes labels Nov 10, 2023
    @gaogaotiantian
    Copy link
    Member

    The issue mentioned above is fixed by #111740, if you have other scenarios where pdb shows internal exceptions please reopen this.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 bugs and security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants