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
[BUG] PyPy-specific compiler crash in a function with fused types #5588
Comments
I wonder if there is some difference in the function signature introspection between CPython and PyPy that leads to the missing |
One thing I wonder (without having done any investigation or tried anything): is this a difference between "Cython compiled to extension modules" and "Cython run as Python code" rather than a difference between CPython and PyPy. That'd seem more likely to me. Because at the point you hit this bug, the generated code should be completely independent of the Python version used to generate it. |
I mean, I have Cython 3.0 installed for both CPython and PyPy; when I try to compile the same code (either with |
Just to explain my comment: the Cython wheels that we distribute for CPython are typically compiled with Cython themselves. The versions we distribute for PyPy typically aren't. I'm guessing that this is more likely to be the difference than PyPy itself. It needs proper investigation though (and not asking you to do the investigation) - that is just a guess at this stage. |
To try it out, you can download the pure Python wheel of Cython from PyPI and install it on CPython, then see if the build fails there, too. (There's also a pip option to avoid binary wheels, but I can't look that up right now.)
|
I tried this, and the CPython build was fine. Additionally, I was able to confirm that this crash is only for PyPy 3.9 and prior, I'm not getting it with PyPy 3.10. |
I've at least got it down to a short reproducible example something.pxd
something.pyx
and just build with |
PyPy bug: https://foss.heptapod.net/pypy/pypy/-/issues/3978 cython/Cython/Compiler/FusedNode.py Lines 201 to 206 in 6776c96
I'm going to leave this open here because what we have in Cython feels fragile. Maybe we should make it so that |
In some Python versions, generating the error message when .index fails to find an index leads to a compiler crash. Fix this by not relying on type being fully set up while generating __str__. Fixes cython#5894 and cython#5588
Describe the bug
When compiling a Cython class
cpdef
method with fused type arguments and default arguments, I get a compiler crash (see next section). This happens only when running Cython withpypy
(PyPy 7.3), the same code compiles fine with CPython (Python 3.10). The error seems to originate fromCython.COmpiler.PyrexTypes
, as shown in the traceback.Code to reproduce the behaviour:
I have a hard time reproducing it because this comes from a larger codebase (althonos/pyhmmer) but I have the following method inside a
cdef class
:where
TopHits
,DigitalMSA
andBuilder
are Cython classes, andSearchTargets
a fused type.I'm getting the following crash, but only when compiling with PyPy, with CPython it compiles fines:
Expected behaviour
The Cython code (and the generated C code) compiles and works.
OS
Linux
Python version
Python 3.10.12 [PyPy 7.3.12 with GCC 13.1.1 20230429]
Cython version
3.0.0
Additional context
I actually tried modifying
PyrexTypes.py
:cython/Cython/Compiler/PyrexTypes.py
Lines 3257 to 3258 in b4671ba
To check that
self.op_arg_struct
is not none:In that case I can compile both the Cython file and the resulting C code succesfully, but maybe that's just a hotfix and it breaks things elswehere 🤷 .
The text was updated successfully, but these errors were encountered: