You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the function __Pyx_PyNumber_IntOrLong from cython raises an exception when the conversion fails. On CPython, this will always be a TypeError from line 314, but on other implementations i.e. PyPy the call to PyNumber_Int on line 298 raises a ValueError upon failure.
Pandas catches only a TypeError. The easiest fix would be for pandas to catch both TypeError and ValueError when conversion fails, a harder fix would be to change cython to raise a ValueError on CPython as well, and then fix all the downstream libraries that use it (Or to scope the call to PyNumber_Int and convert the exception, and then require a minimum cython version for pandas-on-PyPy).
I already have the fix for catching multiple exceptions, should I issue a pull request for that?
The text was updated successfully, but these errors were encountered:
here is a minimal test case that raises in indexes/base.py, Index.__contains__(), line 1592 or so, note __contains__ only catches TypeError
# build extensions with
# CFLAGS='-g -01' python setup.py --inplace --force
# then run
# PYTHONPATH=. gdb --args python /path/to/this/file.py
#
import pandas as pd
r = pd.RangeIndex(4)
print('')
print('xxxxxx test starts here')
print('break into the debuger with <Ctrl-C> and set a breakpoint')
print('b __Pyx_PyNumber_IntOrLong')
print('then "c" to continue from gdb')
print('and "c" again to continue from pdb')
import pdb;pdb.set_trace()
result = 'some string' in r
print result
here is the complete changeset to fix this in pandas. I filed an issue with cython as well, not sure where the best place for a fix is
the function
__Pyx_PyNumber_IntOrLong
from cython raises an exception when the conversion fails. On CPython, this will always be aTypeError
from line 314, but on other implementations i.e. PyPy the call toPyNumber_Int
on line 298 raises aValueError
upon failure.Pandas catches only a
TypeError
. The easiest fix would be for pandas to catch bothTypeError
andValueError
when conversion fails, a harder fix would be to change cython to raise a ValueError on CPython as well, and then fix all the downstream libraries that use it (Or to scope the call toPyNumber_Int
and convert the exception, and then require a minimum cython version for pandas-on-PyPy).I already have the fix for catching multiple exceptions, should I issue a pull request for that?
The text was updated successfully, but these errors were encountered: