简体   繁体   English

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

[英]Why is pdb displaying “*** Blank or comment” when I try to set a Break?

I'm working with my Django app. 我正在使用我的Django应用程序。 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 ) (第20行)

I'm invoking pdb with this line of code: 我用这行代码调用pdb:

import pdb; pdb.set_trace()

However, inside the code, I can't seem to set a Break. 但是,在代码中,我似乎无法设置Break。

(Pdb) b 20  
*** Blank or comment  
(Pdb) break 20  
*** Blank or comment  `

What am I doing wrong? 我究竟做错了什么?

pdb is telling you that line 20 of the file you're in doesn't contain code; pdb告诉你,你所在文件的第20行不包含代码; 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. 使用'list'命令查看当前文件的代码('help list'以获取有关此命令的详细信息),然后在包含可执行代码的行上设置断点。

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. 您还可以使用'where'命令查看堆栈帧,因为您可能不在正确的文件中,因为您没有查看您认为自己的堆栈帧级别。 Use 'up' and 'down' to go to the level of the stack where you want to debug. 使用'up'和'down'转到要调试的堆栈级别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试使用 corsheaders 时,为什么我的应用程序会中断? - Why does my application break when I try to use corsheaders? 为什么不能使用pdb交互式调试器闯入正在运行的测试? - Why can't I break into a running test with the pdb interactive debugger? 为什么在调用pdb.set_trace()时此测试崩溃? - Why does this test crash when pdb.set_trace() is called? 为什么要导入pdb? pdb.set_trace在Spyder中以不同方式调用时会触发两种不同的调试方案? - Why does import pdb; pdb.set_trace trigger two different debugging scenarios when called differently in Spyder? 为什么我不使用 break 语句跳出 try 循环? - Why am I not breaking out of a try loop with a break statement? 如何在源代码中设置pdb中断条件? - How to set pdb break condition from within source code? 如何通过pdb在python类的成员函数中设置断点? - How to set break points in python class's member function by pdb? 为什么当我设置 while var != 0 时循环不会在 0 计数处中断 - why doesn't loop break at 0 count when I set while var != 0 PDB怎么打破退出? - PDB how to break on exit? 为什么在导入 pdb 时会出现此错误? “模块”对象没有属性“ascii_letters” - Why I'm getting this error when I import pdb? 'module' object has no attribute 'ascii_letters'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM