为什么 pdb 显示“*** 空白或注释”当我尝试设置休息时?
我正在使用我的 Django 应用程序。由于某种原因,列表的元素分配不正确。
我试图在我认为发生错误的地方设置一个中断。 (第20行)
我用这行代码调用pdb:
import pdb; pdb.set_trace()
但是,在代码内部,我似乎无法设置中断。
(Pdb) b 20
*** Blank or comment
(Pdb) break 20
*** Blank or comment `
我做错了什么?
I'm working with my Django app. For some reason an element of a list is being assigned incorrectly.
I'm trying to set a break where I think the error is occurring. ( line 20 )
I'm invoking pdb with this line of code:
import pdb; pdb.set_trace()
However, inside the code, I can't seem to set a Break.
(Pdb) b 20
*** Blank or comment
(Pdb) break 20
*** Blank or comment `
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pdb 告诉您所在文件的第 20 行不包含代码;它要么是空白的,要么只包含一条评论。这样的行实际上永远不会被执行,因此不能在其上设置断点。
使用“list”命令查看当前所在文件的代码(有关此命令的详细信息,请使用“help list”),然后在包含可执行代码的行上设置断点。
您还可以使用“where”命令来查看堆栈帧,因为您可能不在正确的文件中,因为您没有查看您认为所在的堆栈帧的级别。使用“向上”和“向下”转到要调试的堆栈级别。
pdb is telling you that line 20 of the file you're in doesn't contain code; it's either blank or just contains a comment. Such a line will never actually be executed, so a breakpoint can't be set on it.
Use the 'list' command to see the code of the file you're currently in ('help list' for details on this command), and then set breakpoints on lines which include executable code.
You can also use the 'where' command to see the stack frame, since you might not be in the right file because you're not looking at the level of the stack frame where you think you are. Use 'up' and 'down' to go to the level of the stack where you want to debug.