unskip and fix some passing tests#5429
Conversation
|
cool, pypy3.9 tests pass on CI. |
|
The pure-python |
Cython/Utility/AsyncGen.c
Outdated
|
|
||
| o->ag_hooks_inited = 1; | ||
|
|
||
| #if CYTHON_COMPILING_IN_CPYTHON |
There was a problem hiding this comment.
I'm not completely sure, but I wonder if CYTHON_USE_TYPE_SLOTS would be the more appropriate check here (and later)
There was a problem hiding this comment.
I am not sure, I thought CYTHON_USE_TYPE_SLOTS is for the documented dunder slots like tp_str -> __str__ as generated by the typeslots.py code generator.
There was a problem hiding this comment.
... which generates these slot functions
There was a problem hiding this comment.
CYTHON_USE_TYPE_SLOTS is for code that directly uses the tp_* slot functions of types, not for attributes on the thread state. There's CYTHON_FAST_THREAD_STATE, but I don't think that applies here, either. That guard controls the way we get at the thread state, more that what we do with it (although that might still depend on how fast we can get our hands on it when we need it).
If this it PyPy specific code, why not use CYTHON_COMPILING_IN_PYPY?
|
There are a number of failing tests in code like I think the failure is due to a difference between |
So, you're saying that calling Does PyPy fill the |
Yes. I added a fix in 859a9a5 to use the type slot on PyPy, with a workaround for PyPy not having |
scoder
left a comment
There was a problem hiding this comment.
Most of this is good to have. I left comments on changes that I found questionable.
Cython/Utility/AsyncGen.c
Outdated
|
|
||
| o->ag_hooks_inited = 1; | ||
|
|
||
| #if CYTHON_COMPILING_IN_CPYTHON |
There was a problem hiding this comment.
CYTHON_USE_TYPE_SLOTS is for code that directly uses the tp_* slot functions of types, not for attributes on the thread state. There's CYTHON_FAST_THREAD_STATE, but I don't think that applies here, either. That guard controls the way we get at the thread state, more that what we do with it (although that might still depend on how fast we can get our hands on it when we need it).
If this it PyPy specific code, why not use CYTHON_COMPILING_IN_PYPY?
Cython/Utility/AsyncGen.c
Outdated
|
|
||
| finalizer = tstate->async_gen_finalizer; | ||
| #else | ||
| finalizer = _PyEval_GetAsyncGenFinalizer(); |
There was a problem hiding this comment.
These were removed from CPython a year ago: python/cpython#32017
That probably means they are not future proof.
There was a problem hiding this comment.
The code-path is for non-CPython compilation. Is there a better way to work around the opaque PyThreadState fields?
There was a problem hiding this comment.
The code-path is for non-CPython compilation.
Right, but the fact that CPython had them and removed them means that other implementation won't necessarily have them either. As long as only PyPy is known to have them, I'd use the PYPY guard instead of the CPYTHON guard here.
Thefunctions were removed from CPython in favour of sys.get_asyncgen_hooks(), which sounds rather annoying to call from C, but we could do that here.
Is there a better way to work around the opaque PyThreadState fields?
It's an opaque struct in the Limited API, not in regular CPython.
|
I related to the review comments. Still not resolved: using getter functions I had to reskip the test: there is too much missing in PyPy to support |
|
CI is passing. I will revert using a nightly build in CI (commit fcf1695) once PyPy releases a version that supports |
scoder
left a comment
There was a problem hiding this comment.
As long as we keep this PyPy specific, it should be safe to merge. As it stands, it also impacts other implementations.
Cython/Utility/AsyncGen.c
Outdated
|
|
||
| finalizer = tstate->async_gen_finalizer; | ||
| #else | ||
| finalizer = _PyEval_GetAsyncGenFinalizer(); |
There was a problem hiding this comment.
The code-path is for non-CPython compilation.
Right, but the fact that CPython had them and removed them means that other implementation won't necessarily have them either. As long as only PyPy is known to have them, I'd use the PYPY guard instead of the CPYTHON guard here.
Thefunctions were removed from CPython in favour of sys.get_asyncgen_hooks(), which sounds rather annoying to call from C, but we could do that here.
Is there a better way to work around the opaque PyThreadState fields?
It's an opaque struct in the Limited API, not in regular CPython.
That is actually what the PyPy implementation does. Would it be OK if I make the code path with the pypy-specific functions pypy-only? |
|
close/reopen to trigger CI |
scoder
left a comment
There was a problem hiding this comment.
LGTM now. I'll wait for CI and then merge this.
|
Thanks! |
|
As commented in pypy issue 3280
Would it be OK to backport this to the 0.29.x branch? |
|
Would it be OK to backport this to the 0.29.x branch?
Yes, that would be fine. The whole patch might not apply cleanly, but at least the test part is not strictly needed then.
|
Currently require a nightly PyPy build for Py3.9 to support async iteration and finalisation. Avoid PyIter_Next() and call tp_iternext() instead because PyIter_Next() swallows StopIteration exceptions and thus looses the return value. See https://foss.heptapod.net/pypy/pypy/-/issues/3280 See https://foss.heptapod.net/pypy/pypy/-/issues/3935
* Fixes for PyPy (GH-5429) Currently require a nightly PyPy build for Py3.9 to support async iteration and finalisation. Avoid PyIter_Next() and call tp_iternext() instead because PyIter_Next() swallows StopIteration exceptions and thus looses the return value. See https://foss.heptapod.net/pypy/pypy/-/issues/3280 See https://foss.heptapod.net/pypy/pypy/-/issues/3935 * change MACOSX_DEPLOYMENT_TARGET to 11.0
PyPy3.9 passes these tests, once the
sys.getrefcountpart is skipped. I am working on gettingtest_asyncgento pass so grpcio work with PyPY, see pypy issue 3280 and pypy issue 3935