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 debugs itself after ^C and a breakpoint is set anywhere #58993

Open
xdegaye mannequin opened this issue May 12, 2012 · 3 comments
Open

Pdb debugs itself after ^C and a breakpoint is set anywhere #58993

xdegaye mannequin opened this issue May 12, 2012 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented May 12, 2012

BPO 14788
Nosy @birkenfeld, @blueyed, @xdegaye
Files
  • pdb_default.patch
  • 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 2012-05-12.10:07:36.784>
    labels = ['type-bug', 'library']
    title = 'Pdb debugs itself after ^C and a breakpoint is set anywhere'
    updated_at = <Date 2019-04-19.10:51:51.502>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2019-04-19.10:51:51.502>
    actor = 'blueyed'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2012-05-12.10:07:36.784>
    creator = 'xdegaye'
    dependencies = []
    files = ['25547']
    hgrepos = []
    issue_num = 14788
    keywords = ['patch']
    message_count = 3.0
    messages = ['160467', '222267', '340536']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'blueyed', 'xdegaye']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue14788'
    versions = ['Python 3.4', 'Python 3.5']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 12, 2012

    When a breakpoint is set anywhere (in which case the global system's
    trace function is set), interrupting the debuggee causes Pdb to stop
    into its own code. See the following pdb session run with python on
    the current head of the default branch from the repo.

    === main.py =================================

    import time
    def bar():
        i = 1
        while i:
            time.sleep(.100)
    
    bar()

    =================================================

    $ python -m pdb main.py
    > /path_to/main.py(1)<module>()
    -> import time
    (Pdb) import sys; print(sys.version)
    3.3.0a3+ (default:4e9680570be8, May 11 2012, 12:09:15) 
    [GCC 4.3.2]
    (Pdb) break bar
    Breakpoint 1 at /path_to/main.py:2
    (Pdb) continue
    > /path_to/main.py(3)bar()
    -> i = 1
    (Pdb) continue
    ^C
    Program interrupted. (Use 'cont' to resume).
    --Call--
    > /home/xavier/src/cpython/cpython-hg-default/Lib/bdb.py(212)set_trace()
    -> def set_trace(self, frame=None):
    (Pdb) where
      /home/xavier/src/cpython/cpython-hg-default/Lib/bdb.py(405)run()
    -> exec(cmd, globals, locals)
      <string>(1)<module>()
      /path_to/main.py(7)<module>()
    -> bar()
      /path_to/main.py(5)bar()
    -> time.sleep(.100)
      /home/xavier/src/cpython/cpython-hg-default/Lib/pdb.py(196)sigint_handler()
    -> self.set_trace(frame)
    > /home/xavier/src/cpython/cpython-hg-default/Lib/bdb.py(212)set_trace()
    -> def set_trace(self, frame=None):
    (Pdb) quit

    =================================================

    The attached patch fixes the problem and includes a test case. This
    fix is the same as the one proposed at bpo-14743 to fix another
    problem, except that the set_step call is moved at the end of the
    sigint_handler method for the sake of robustness.

    @xdegaye xdegaye mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 12, 2012
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 4, 2014

    A quick glance tells me the patch is okay, apart from the name "test_issue_XXX", so can we have a formal patch review please. See also bpo-14743.

    @blueyed
    Copy link
    Mannequin

    blueyed mannequin commented Apr 19, 2019

    I think this issue itself might be fixed already / changed since 3.5.

    I've came up with something similar in this area though, which is only triggered when using Ctrl-C while pdb is waiting for the next statement: #12880

    @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

    0 participants