-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Get 0.29.x working on Python 3.11 #4465
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
Conversation
* Add a basic replacement for PyCode_New(). An optimized versions would be nice, but this is intended to work sufficiently to start testing. Also, CPython 3.11 might actually add a new C-API function to simplify setting the current code position. That might be used instead. * Disable introspection of frame object with vectorcall This feature looked to only be used for early Python versions that don't have the full vectorcall protocol (and the contents of the frame object are changed in Python 3.11).
…ythonGH-4427) Use the accessor function instead of the direct struct member (which is now the wrong type). Closes cython#4416
As an aside - this might be a good reason to target a release of Cython 3.0 sooner rather than later - it sort of feels like Cython the features needed to support modern versions of Python are in the Cython 3alpha only and it's beginning to diverge too much to easily maintain both. |
Finally comment for now: It's probably possible to dedefine |
That's fine. Users who really want Py3.11 support (and all of the other goodies) can switch to Cython 3.0 now. Everyone who chooses not to do that can certainly live with a reduced feature set, since that's specifically what they choose. |
Cython/Utility/Coroutine.c
Outdated
// FIXME: unclear what to do if PyThreadState_GetFrame fails | ||
f->f_back = PyThreadState_GetFrame(tstate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs say that it returns NULL
is there is no current frame. That seems reasonable and not a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the comment then. That should probably be updated in master too
Closing and reopening to get a CI run. |
Not complete, but good enough for a merge. Thanks! |
Thanks for this cool fix! I found this PR while trying to write a fix for Would it be possible to have a Cython 0.29.x release including this fix? It would help me to test my other changes to port projects to Python 3.11, like python/mypy#11652 : running the mypy test suite requires to install lxml which uses Cython ;-) |
Yeah, I was planning for new releases a few times but ran into various issues each time I tried. 0.29 finally has CI support again, so it's much safer now to try a release again. I'll give it another try soon. |
Oh obvisouly, please tell me if I can help you ;-) |
FYI, 0.29.25 is out. |
Yeah, that's great! Thanks a lot @scoder! It's great to have Cython compatible with alpha versions of Python, it helps me a lot for testing. |
This is a cherry pick of 9d1ffd5 and 3f56484 for Cython 0.29.x. It is not a hugely clean cherry-pick because
__Pyx_PyCode_New
has a different number of arguments in the two versions.It also disables
CYTHON_FAST_PYCALL
on Python 3.11 (which I imagine is a performance regression). This is because the frame object no longer has af_localsplus
field to use. On Cython 3 this is fine - we useCYTHON_VECTORCALL
instead, however that doesn't exist on 0.29.x. Therefore this is the least intrusive change available I think.I've tested it to the extent of building Cython with these changes with Python versions 2.7, 3.7, 3.8, 3.9, 3.10, and 3.11 (twice, so it builds, then runs the compiled cython to rebuild itself) but haven't run anything more of the test-suite.