为什么 pdb 显示“*** 空白或注释”当我尝试设置休息时?

发布于 2024-08-13 12:11:54 字数 304 浏览 4 评论 0原文

我正在使用我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2024-08-20 12:11:54

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文