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

pdb.Pdb.checkline() throws AttributeError if called before starting a debug session #53476

Closed
Vano mannequin opened this issue Jul 12, 2010 · 2 comments
Closed

pdb.Pdb.checkline() throws AttributeError if called before starting a debug session #53476

Vano mannequin opened this issue Jul 12, 2010 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Vano
Copy link
Mannequin

Vano mannequin commented Jul 12, 2010

BPO 9230
Nosy @birkenfeld, @bitdancer
Files
  • pdb_checkline.patch: bugfix
  • 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 2010-07-30.07:21:33.194>
    created_at = <Date 2010-07-12.03:56:28.591>
    labels = ['type-bug', 'library']
    title = 'pdb.Pdb.checkline() throws AttributeError if called before starting a debug session'
    updated_at = <Date 2010-07-30.07:21:33.116>
    user = 'https://bugs.python.org/Vano'

    bugs.python.org fields:

    activity = <Date 2010-07-30.07:21:33.116>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-30.07:21:33.194>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2010-07-12.03:56:28.591>
    creator = '__Vano'
    dependencies = []
    files = ['17955']
    hgrepos = []
    issue_num = 9230
    keywords = ['patch']
    message_count = 2.0
    messages = ['110065', '112045']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'r.david.murray', '__Vano']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9230'
    versions = ['Python 2.7']

    @Vano
    Copy link
    Mannequin Author

    Vano mannequin commented Jul 12, 2010

    pdb.Pdb.checkline() throws AttributeError at pdb.py:470 if invoked before starting a debugging session because self.curframe doesn't exist at that time.

    This breaks IPython's %run magic command (v0.10, Magic.py:1663). The command sets a breakpoint before running the script and scans the file before that to make sure the breakpoint is set on an executable line.

    This is a reasonable thing to do: setting a breakpoint and making sure it is set correctly shouldn't require a running debug session. So i conclude it is pdb, not IPython, that shall be fixed.

    The patch attached gives linecache.getline() None as module_globals if self.curframe doesn't exist.

    The rationale is: even if the script does use PEP-302 import stuff, we can't know or use that before running it. So it's ok if we stay limited with usual paths.

    @Vano Vano mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jul 12, 2010
    @birkenfeld
    Copy link
    Member

    Thanks, fixed in r83261.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant