How to set breakpoints in a library module (pdb)

 ̄綄美尐妖づ 提交于 2019-12-23 07:49:32

问题


I am debugging a python script which sys.path looks like

sys.path = ['','home/my_library', ..]

I'm having troubles to set a breakpoint in a module from my_library while using pdb. The script imports the library with:

import my_library as foo

In turn, my_library makes its module(s) available by:

from my_module import bar

How can address my_module's code while running pdb on my script?

PS: I have tried the followings without success:

b my_module:1
b my_library.my_module:1
b my_library.bar:1
b foo.my_module:1
b foo.bar:1

回答1:


You qualify the breakpoints with the filename, not the object name:

>>> import pdb
>>> import artwork  # module we want to break inside
>>> pdb.set_trace()
--Return--
> <console>(1)<module>()->None
(Pdb) b artwork/models.py:1
Breakpoint 1 at /home/user/projects/artwork/models.py:1

See also this answer.



来源:https://stackoverflow.com/questions/23071175/how-to-set-breakpoints-in-a-library-module-pdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!