This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Pdb incorrectly handles a method breakpoint when module not imported
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, xdegaye
Priority: normal Keywords: patch

Created on 2012-05-13 15:25 by xdegaye, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
pdb_default.patch xdegaye, 2012-05-13 15:25 review
Messages (2)
msg160517 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2012-05-13 15:25
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)<module>()
-> 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)<module>()
-> 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.
msg161573 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2012-05-25 11:55
Parsing the modules source seems a better way to fix this problem, see issue 14913.
History
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 59000
2012-05-25 11:55:57xdegayesetmessages: + msg161573
2012-05-18 17:49:46terry.reedysetnosy: + georg.brandl
2012-05-13 15:25:56xdegayecreate