pdb 跳过了一个隐藏帧问题

pdb skipped one hidden frame issue

每当我尝试 运行 单元格中的程序时,它都会给我一个奇怪的错误。

test_pts = sorted_points
new_segments = []
import pdb; pdb.set_trace()
for i in range(0, len(test_pts)-1):
    x1 = test_pts[i][0]; y1 = test_pts[i][1]; x2 = test_pts[i][2]; y2 = test_pts[i][3]; angle1 = test_pts[i][4]
    print(x1, y1, x2, y2, angle1)
    for j in range(i + 1, len(test_pts)):
        n_x1 = test_pts[j][0]; n_y1 = test_pts[j][1]; n_x2 = test_pts[j][2]; n_y2 = test_pts[j][3]; angle2 = test_pts[j][4]
        if (isclose(angle1, angle2, rel_tol = 1)) and (isclose(x1, x2, rel_tol = 1) and (isclose(y1, y1, rel_tol = 1))):
            
            print(n_x1, n_y1, n_x2, n_y2, angle2) 
            break  

下面的堆栈跟踪 -> 我觉得这个问题不可重现,甚至不是特定于代码的,即我编写的​​代码没有任何问题,但我无法弄清楚是什么导致这种行为。

# %% LINE EXTENSION - CONNECT...
--Return--
None
> (3)()
      1 test_pts = sorted_points
      2 new_segments = []
----> 3 import pdb; pdb.set_trace()
      4 for i in range(0, len(test_pts)-1):
      5     x1 = test_pts[i][0]; y1 = test_pts[i][1]; x2 = test_pts[i][2]; y2 = test_pts[i][3]; angle1 = test_pts[i][4]

    [... skipped 1 hidden frame]

> /home/and/CERLAB/lib/python3.8/site-packages/IPython/core/interactiveshell.py(3346)run_code()
   3344             finally:
   3345                 # Reset our crash handler in place
-> 3346                 sys.excepthook = old_excepthook
   3347         except SystemExit as e:
   3348             if result is not None:

我仍然不确定问题到底是什么 - 这不是发生在普通 python 文件中的事情,似乎只发生在 .ipnyb 文件中。

这样设置的断点只有在函数内部才有效,否则无效。所以基本上,如果您 运行 遇到这个问题,请确保该语句在函数内部。