I'm relatively new to python and pdb, but I have a lot of experience with gdb.
My problem is that if I set a number of breakpoints in my code at some point I will want to change something and re-run my debug session retaining these break points. However entering "run" in my pdb session cases my session to terminate with the following output
(Pdb) run
Traceback (most recent call last):
File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/usr/lib64/python2.6/pdb.py", line 1319, in <module>
pdb.main()
File "/usr/lib64/python2.6/pdb.py", line 1312, in main
pdb.interaction(None, t)
File "/usr/lib64/python2.6/pdb.py", line 198, in interaction
self.cmdloop()
File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "/usr/lib64/python2.6/pdb.py", line 267, in onecmd
return cmd.Cmd.onecmd(self, line)
File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
return func(arg)
File "/usr/lib64/python2.6/pdb.py", line 661, in do_run
raise Restart
pdb.Restart
]$
I've tried this on two independent linux platforms and had the same result but I cannot find any corrections in the documentation.
Here is my file test.py:
import pdb
pdb.set_trace()
print('1 line')
I get the same error when I using command 'python3 test.py':
> /home/wangpq/program_note/test.py(3)<module>()
-> print('1 line')
(Pdb) run
Traceback (most recent call last):
File "program_note/test.py", line 3, in <module>
print('1 line')
File "program_note/test.py", line 3, in <module>
print('1 line')
File "/usr/lib/python3.5/bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib/python3.5/bdb.py", line 66, in dispatch_line
self.user_line(frame)
File "/usr/lib/python3.5/pdb.py", line 259, in user_line
self.interaction(frame, None)
File "/usr/lib/python3.5/pdb.py", line 346, in interaction
self._cmdloop()
File "/usr/lib/python3.5/pdb.py", line 319, in _cmdloop
self.cmdloop()
File "/usr/lib/python3.5/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "/usr/lib/python3.5/pdb.py", line 412, in onecmd
return cmd.Cmd.onecmd(self, line)
File "/usr/lib/python3.5/cmd.py", line 217, in onecmd
return func(arg)
File "/usr/lib/python3.5/pdb.py", line 1022, in do_run
raise Restart
pdb.Restart
Then I use command 'python3 -m pdb test.py'
wangpq@wangpq:~$ python3 -m pdb program_note/test.py
> /home/wangpq/program_note/test.py(1)<module>()
-> import pdb
(Pdb) restart
Restarting program_note/test.py with arguments:
program_note/test.py
> /home/wangpq/program_note/test.py(1)<module>()
-> import pdb
(Pdb)
It works. So far, I am not sure why this happens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With