Skip to content

COMPAT: __Pyx_PyNumber_IntOrLong raises ValueError on PyPy #16336

Closed
@mattip

Description

@mattip

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions