Skip to content

running set_trace() multiple times displays stdlib bdb.py #52

Closed
@bukzor

Description

@bukzor

Reproduction steps:

  1. Save below script as foobar.py
  2. python foobar.py foo bar
  3. You'll break at function foo
  4. Defined a breakpoint at foobar.py:11 (the first line of main(): for arg in argv:)
  5. c
  6. You'll be brought to line 11
  7. c
  8. You'll be brought to /usr/lib/python2.6/bdb.py at _ste_stopinfo(), and also see that you now have two breakpoints at foobar.py:11
  9. Pressing s fourteen times eventually brings you to the correct breakpoint in bar()

The expected behavior is to not display bdb.py, and not create duplicate breakpoints.

Obviously there are other ways to accomplish the desired debugging session, but in a large, complex code base, it is sometimes extremely convenient to have multiple set_trace lines, which may or may not cause set_trace to be called twice.

If you can tell me how to induce this error automatically, I can write a unit test for it, at minimum, and likely produce a patch for the bug as well.

# Script: foobar.py
def foo():
    import pudb; pudb.set_trace()
    print 'foo'

def bar():
    import pudb; pudb.set_trace()
    print 'bar'

def main(argv):
    for arg in argv:
        if arg == 'foo':
            foo()
        elif arg == 'bar':
            bar()

import sys
main(sys.argv)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions