Issue 14795: Pdb incorrectly handles a method breakpoint when module not imported (original) (raw)

In the following test, breakpoint 2 is set incorrectly at line 1 and pdb does not know how to set a breakpoint on method C.c_foo. However setting those two breakpoints on both methods is ok after the class definition has been executed.

=== main.py ================================= def foo(): pass

class C: def c_foo(self): pass def foo(self): pass

foo()

$ python3.1 -m pdb main.py > /path_to/main.py(1)() -> def foo(): (Pdb) import sys; print(sys.version) 3.1.2 (r312:79147, Apr 4 2010, 17:46:48) [GCC 4.3.2] (Pdb) break foo Breakpoint 1 at /path_to/main.py:1 (Pdb) break C.foo Breakpoint 2 at /path_to/main.py:1 (Pdb) break C.c_foo *** The specified object 'C.c_foo' is not a function or was not found along sys.path. (Pdb) break 10 Breakpoint 3 at /path_to/main.py:10 (Pdb) continue > /path_to/main.py(10)() -> foo() (Pdb) break C.foo Breakpoint 4 at /path_to/main.py:7 (Pdb) break C.c_foo Breakpoint 5 at /path_to/main.py:5 (Pdb) quit

The attached patch fixes the problem. The patch includes a test case.