[New-bugs-announce] [issue46535] Possible bug: pdb causes exception

Stefan Ecklebe report at bugs.python.org
Wed Jan 26 06:20:07 EST 2022

New submission from Stefan Ecklebe <stefan.ecklebe at tu-dresden.de>:

Consider a script called snippet.py, containing the lines

import numpy as np
import pandas as pd

idx = pd.MultiIndex.from_tuples([(1, 2)])

When running via 'python snippet.py' no errors occur. However when running via 'python -m pdb snippet.py' the following happens:
> snippet.py(1)<module>()
-> import numpy as np
(Pdb) r
> snippet.py(6)<module>()->None
-> np.finfo(float)
(Pdb) c
Traceback (most recent call last):
  File "VENV/lib/python3.10/site-packages/numpy/core/getlimits.py", line 459, in __new__
    dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/pdb.py", line 1723, in main
  File "/usr/lib/python3.10/pdb.py", line 1583, in _runscript
  File "/usr/lib/python3.10/bdb.py", line 597, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "snippet.py", line 6, in <module>
  File "VENV/lib/python3.10/site-packages/numpy/core/getlimits.py", line 462, in __new__
    dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program

Commenting the MultiIndex line will will get rid of the problem but I am not quite sure why.

Please note that this error only occurs if the script is run via 'r' in pdb. Running via 'c' does not cause any problems.
Therefore, I suspect that the problem may be with pdb instead of the external packages.

My setup:
$ python --version
Python 3.10.1
$ pip list | grep numpy
numpy                1.22.1
$ pip list | grep pandas
pandas               1.4.0

components: Library (Lib)
messages: 411738
nosy: cklb
priority: normal
severity: normal
status: open
title: Possible bug: pdb causes exception
type: crash
versions: Python 3.10

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list