Consider a script called snippet.py, containing the lines
------------------------------------------
import numpy as np
import pandas as pd
np.finfo(float)
idx = pd.MultiIndex.from_tuples([(1, 2)])
np.finfo(float)
print("Done")
------------------------------------------
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
--Return--
> 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
pdb._runscript(mainpyfile)
File "/usr/lib/python3.10/pdb.py", line 1583, in _runscript
self.run(statement)
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>
np.finfo(float)
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
|