pythondebuggingipythonpdbipdb

ipdb commands obscured by variables


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 n = 1
----> 2 next = 1
      3 print('end')

ipdb> next
> /tmp/test.py(3)<module>()
      1 n = 1
      2 next = 1
----> 3 print('end')

ipdb> next
1
ipdb> n
1
ipdb> !n
1
ipdb> !next
1

How can i proceed further with my code execution when both commands (n/next) aren't recognized anymore? (Let's assume s/step are also obscured by variables).

What i tried so far:

I'm using

EDIT

The issue was fixed by by: https://github.com/ipython/ipython/pull/10050


Solution

  • Update in 12/14/2016:

    Finally the iPython team decide to revoke this design.


    The solution of your problem is use !! statement to force standard behavior.

    > /home/v-zit/test.py(1)<module>()
    ----> 1 n = 1
          2 next = 11
          3 print('end')
    
    ipdb> n
    > /home/v-zit/test.py(2)<module>()
          1 n = 1
    ----> 2 next = 11
          3 print('end')
    
    ipdb> n
    1
    ipdb> !!n
    > /home/v-zit/test.py(3)<module>()
          1 n = 1
          2 next = 11
    ----> 3 print('end')
    
    ipdb> next
    11
    ipdb> !!next
    end
    --Return--
    None
    > /home/v-zit/test.py(3)<module>()
          1 n = 1
          2 next = 11
    ----> 3 print('end')
    
    ipdb>
    

    Reference:

    https://github.com/ipython/ipython/pull/9449

    https://github.com/ipython/ipython/pull/10050