Pdb Crashed: Cannot set breakpoint

2019-08-27 03:47发布

I suddenly cannot set any breakpoint in my python program. Note there are two (Pdb) showing up. I wonder if the Pdb was damaged before. I did try to step into some compiled C++ code in an abc.so file using Pdb before this issue started happening:

-> print('haha')
(Pdb) (Pdb) 
Traceback (most recent call last):
  File "high.py", line 38, in <module>
    print('haha')
  File "high.py", line 38, in <module>
    print('haha')
  File "/Users/ludaming/anaconda2/lib/python2.7/bdb.py", line 49, in trace_dispatch
    return self.dispatch_line(frame)
  File "/Users/ludaming/anaconda2/lib/python2.7/bdb.py", line 68, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit

1条回答
SAY GOODBYE
2楼-- · 2019-08-27 04:11

Now I figured it out that the Pdb is not malfunctioning. It is because Python reads from stdin right next to the Pdb, which enters to the Pdb's interactive console and causing a problem. So a bypass is to read from file instead of stdin

fp = open(sys.argv[1], 'r')  
t = int(fp.readline())

instead of

t = int(raw_input())
查看更多
登录 后发表回答