41

What does this mean?

My function gets two numpy arrays from a python/c library. After that function call I turn on the debugger to find a bug, so I add the line to look at the two numpy arrays.

    import pdb; pdb.set_trace()

But for the values of one of the arrays pdb only returns the message *** Newest frame

PDB output:

(Pdb) type(d)
<type 'numpy.ndarray'>
(Pdb) type(f)
<type 'numpy.ndarray'>
(Pdb) f.shape
(3, 3, 17856)
(Pdb) d[0].shape
*** Newest frame
(Pdb) d[0]
*** Newest frame
Framester
  • 33,341
  • 51
  • 130
  • 192

1 Answers1

68

The command d is the command for the debugger used to go down the stack to a 'newer frame'. It seems that the parsing cannot not handle this disambiguity.

Try renaming the variable d.

EDIT: Actually, the comments suggest much better handling than renaming.

Jan
  • 4,932
  • 1
  • 26
  • 30
  • 9
    or do `p d[0].shape` or `print d[0].shape` – Francesco Montesano Mar 01 '13 at 15:52
  • 10
    Or use an exclamation mark if you want to use Python code in the debugger: `!d[0]`. Normally, anything you enter on the debugger cmdline is consider a *debugger* command, not Python (but the debugger is quite flexible). See near the end of the [documentation](http://docs.python.org/2/library/pdb.html). –  Mar 01 '13 at 16:15
  • 4
    The (unfortunately deleted) [answer by Alex E](https://stackoverflow.com/a/50647464/1967396) has a very good suggestion for a workaround - simply type `print(d)` in the debugger. This answer would be stronger if it added that suggestion. – Floris Mar 23 '20 at 21:04
  • Funny I just hit the same issue, in the debugger, just by typind d = blah() which my fingers are sitting on all the time, so...... the variable was 'd' which I changed to 'xx' and all went happy. – AlexD Jan 18 '23 at 21:44