pdb

Strange behaviour of the program after modifying the dictionary of local variables

Strange behaviour of the program after modifying the dictionary of local variables Question: I find some strange behavior in my program after modifying the dictionary of local variables, and it makes me confused. If we execute the code below, we will get the result as the image I attached. And now I know I shouldn’t …

Total answers: 1

How to use pdb correctly without executing the whole file first

How to use pdb correctly without executing the whole file first Question: This is my .pdbrc file contents: b 2 c This is my code.py contents: print(‘1st line’) print(‘2nd line’) print(‘3rd line’) And when I run this command in terminal: python3 -m pdb code.py I get this output: 1st line 2nd line 3rd line Breakpoint …

Total answers: 1

How can I force PDB to quit when the signal is being caught?

How can I force PDB to quit when the signal is being caught? Question: PDB’s quit command works by raising an exception (Bdb.BdbQuit). If that exception gets caught, I cannot figure out a way to kill the program short of killing the entire shell. CTRL+C works by raising a KeyboardInterrupt exception, which can also be …

Total answers: 2

Odoo.sh Editor on Jupyter : pdb.set_trace raises BdbQuit Error

Odoo.sh Editor on Jupyter : pdb.set_trace raises BdbQuit Error Question: Using my odoo.sh project (v13.0.2) > EDITOR-Tab , which redirects me to mywebsite.odoo.com/odoo-sh/editor/lab, when i want to debug using import pdb; pdb.set_trace(), it raises a BdbQuit Error : File "/usr/lib/python3.6/bdb.py", line 113, in dispatch_exception if self.quitting: raise BdbQuit In the past versions : v13.0.1.xxx, i …

Total answers: 1

How to check the version of the currently installed `pdb` (Python Debugger)?

How to check the version of the currently installed `pdb` (Python Debugger)? Question: To check the version of the specific python module, I heard that the following is one of the standard way: python -c ‘import some_module; print (__some_module__.version)’ But for the python debugger ‘pdb’, the above idea doesn’t work. Then how can we check …

Total answers: 3

How to debug a Python module run with python -m from the command line?

How to debug a Python module run with python -m from the command line? Question: I know that a Python script can be debugged from the command line with python -m pdb my_script.py if my_script.py is a script intended to be run with python my_script.py. However, a python module my_module.py should be run with python …

Total answers: 6

How to input from the Python debugger (pdb)

How to input from the Python debugger (pdb) Question: The question is best illustrated by the following simple example. I am using pdb to debug the following script (it is Python 3): astring = input("input here: ") when stepping in the above line, I get the following prompt and type "abc": input here: abc But whatever …

Total answers: 2

pdb: "var = value" did not create the var in current function?

pdb: "var = value" did not create the var in current function? Question: See following example: $ cat -n foo.py 1 def func(): 2 v = another_func() 3 print v 4 5 func() $ pdb foo.py > /root/tmp/foo.py(1)<module>() -> def func(): (Pdb) break 2 Breakpoint 1 at /root/tmp/foo.py:2 (Pdb) cont > /root/tmp/foo.py(2)func() -> v = …

Total answers: 1

ipdb commands obscured by variables

ipdb commands obscured by variables Question: When i try to debug this sample script with ipdb: n = 1 next = 1 print(‘end’) I can’t execute line 3 because python variables obscure pdb commands: $ ipdb test.py > /tmp/test.py(1)<module>() —-> 1 n = 1 2 next = 1 3 print(‘end’) ipdb> next > /tmp/test.py(2)<module>() 1 …

Total answers: 2

How to quit ipdb while in post-mortem debugging?

How to quit ipdb while in post-mortem debugging? Question: I like to inspect error in a Python script by using: $ python3 -m pdb my_script.py This drops me into a pdb prompt from where I can c continue the execution, and when it hits error, I can inspect the variables and then q quit the …

Total answers: 3