0

I'm trying to use the IPython debugger when an error occurs in my script, starting it like so:

ipython --InteractiveShell.pdb true [script_name]

While I use the debugger, if I try to assign to a new variable name, the debugger spontaneously quits. For example, suppose I attempt to debug some code that causes a TypeError:

aa = 'asdf'
bb = 1
something_stupid = aa + bb

My debug session looks like so:

ipdb> aa                                                
'asdf'                                                  
ipdb> bb                                                
1                                                       
ipdb> aa = 'qwer'                                       
ipdb> aa                                                
'qwer'                                                  
ipdb> c = 1                                             
imbackonthecommandline:path/to/directory$

I can see already existing variables, and I can update values of existing variables, but new variables cause a crash. I have tried updating ipython and restarting computer; this does not fix the problem.

I am using Debian from within Windows Subsystem for Linux, on Windows 10. Versions:

$ python --version                     
Python 3.9.6                                                                         
$ ipython --version                    
7.29.0                                                                               

What is wrong, and how do I fix it?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Anton
  • 365
  • 2
  • 12
  • 1
    Does this answer your question? [In ipdb, how to query a variable which as the same name as a command?](https://stackoverflow.com/questions/45678350/in-ipdb-how-to-query-a-variable-which-as-the-same-name-as-a-command) – Karl Knechtel Sep 02 '23 at 14:28
  • No, but it does add extra useful information to the answer below, namely how to escape the command names when conflict. Good addition! – Anton Sep 02 '23 at 17:34

1 Answers1

0

Found my mistake!

c is the 'continue' command in the debugger.

Upon
c = 1
the interpreter stops reading after 'c' and invokes 'continue', sending me back to the command line.
cc = 1
is fine.

Other single letters are also debugger commands, so watch out for those. Examples are u, and d.
Here is the list of debugger commands for the base python debugger pdb https://docs.python.org/3/library/pdb.html#debugger-commands
ipython has probably followed those conventions with their upgraded version.

Hopefully this saves someone an hour mucking around with their debugger.

Anton
  • 365
  • 2
  • 12