Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug: pdb causes exception #90693

Closed
cklb mannequin opened this issue Jan 26, 2022 · 12 comments
Closed

Possible bug: pdb causes exception #90693

cklb mannequin opened this issue Jan 26, 2022 · 12 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@cklb
Copy link
Mannequin

cklb mannequin commented Jan 26, 2022

BPO 46535
Nosy @cklb

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-01-26.11:20:07.032>
labels = ['type-bug', 'library', '3.10']
title = 'Possible bug: pdb causes exception'
updated_at = <Date 2022-01-27.15:39:46.150>
user = 'https://github.com/cklb'

bugs.python.org fields:

activity = <Date 2022-01-27.15:39:46.150>
actor = 'cklb'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-01-26.11:20:07.032>
creator = 'cklb'
dependencies = []
files = []
hgrepos = []
issue_num = 46535
keywords = []
message_count = 1.0
messages = ['411738']
nosy_count = 1.0
nosy_names = ['cklb']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46535'
versions = ['Python 3.10']

@cklb
Copy link
Mannequin Author

cklb mannequin commented Jan 26, 2022

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

@cklb cklb mannequin added type-crash A hard crash of the interpreter, possibly with a core dump 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 26, 2022
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@damarvin
Copy link

Hi,
I see this when debugging in PyCharm, and I cannot downgrade to python 3.9.

(besides commenting out the try-except in numpy/core/getlimits.py::finfo.__new__)
Is there a workaround?

@iritkatriel
Copy link
Member

@cklb

Are you still seeing this problem? I'm unable to reproduce it with Python 3.10.4. (numpy-1.23.0, pandas-1.4.3).

iritkatriel@Irits-MBP cpython-654 % python3.10 -m pdb xx.py         
> /Users/iritkatriel/src/cpython-654/xx.py(1)<module>()
-> import numpy as np
(Pdb) r
Done
--Return--
> /Users/iritkatriel/src/cpython-654/xx.py(7)<module>()->None
-> print("Done")
(Pdb) c
The program finished and will be restarted
> /Users/iritkatriel/src/cpython-654/xx.py(1)<module>()
-> import numpy as np
(Pdb) list
  1  ->	import numpy as np
  2  	import pandas as pd
  3  	
  4  	np.finfo(float)
  5  	idx = pd.MultiIndex.from_tuples([(1, 2)])
  6  	np.finfo(float)
  7  	print("Done")
  8  	

@iritkatriel iritkatriel added the pending The issue will be closed if no feedback is provided label Jul 8, 2022
@cklb
Copy link

cklb commented Jul 19, 2022

@iritkatriel sorry for the delay

I just reran the snippet with the following configuration:

Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
numpy==1.23.1
pandas==1.4.0

and still get the following output:

python -m pdb snippet.py
> /PATH/snippet.py(1)<module>()
-> import numpy as np
(Pdb) r
--Return--
> /PATH/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 460, 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 1726, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python3.10/pdb.py", line 1586, 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 "/PATH/snippet.py", line 6, in <module>
    np.finfo(float)
  File "/VENV/lib/python3.10/site-packages/numpy/core/getlimits.py", line 463, 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
> /VENVl/lib/python3.10/site-packages/numpy/core/getlimits.py(463)__new__()
-> dtype = numeric.dtype(type(dtype))
(Pdb) 

@iritkatriel
Copy link
Member

Have you reported this on the numpy bug tracker?

@cklb
Copy link

cklb commented Jul 19, 2022

Negative. I also did not open an issue in the pandas repo. However, if you think that this help I'll gladly do so.

@iritkatriel
Copy link
Member

The exception is coming from numpy code, so I would start there. If it's a cpython bug they will know how to narrow it down to a small reproducer that doesn't involve so many dependencies.

@cklb
Copy link

cklb commented Jul 20, 2022

I just had a look at the numpy bugtracker and it seems like this actually was a cython issue:

My fault was to only update numpy, but pandas was also still using the affected cython version:

After updating to v1.4.3 of pandas the code now behaves as expected in the debugger 😄

Thank you very much for looking into this.

@iritkatriel iritkatriel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2022
@erlend-aasland erlend-aasland removed the pending The issue will be closed if no feedback is provided label Jul 20, 2022
@Kaliteli
Copy link

.traceback (most recent call last):
File "/usr/lib/python3.10/pdb.py", line 1726, in main
pdb._runscript(mainpyfile)
File "/usr/lib/python3.10/pdb.py", line 1586, in _runscript
self.run(statement)
File "/usr/lib/python3.10/bdb.py", line 597, in run
exec(cmd, globals, locals)
File "", line 1, in
ValueError: source code string cannot contain null bytes
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program

@iritkatriel
Copy link
Member

@Kaliteli can you give some context for your comment?

@Kaliteli
Copy link

Anlayamıyorum

@isidentical
Copy link
Sponsor Member

@Kaliteli can you please check versions of the local libraries you are using (pip freeze) and ensure that they are up to date? Also, let's try to keep the communication in this tracker in English.

Lütfen kullandığınız yerel kütüphanelerin sürümlerini ("pip freeze" ve "python --version") kontrol edip güncel olduklarından emin olur musunuz? Ayrıca GitHub'daki iletişimi ingilizce tutmaya çalışalım.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

6 participants