-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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] Generators after being cythonized cannot be inspect as generators #6096
Comments
I initiate the discussion of this issue here. |
It works for me on Cython 3.0.9 with Python 3.11.5. Have you set the directive |
Fun fact: I found on the repository a comment that was not made by me but never called to my attention: ext_modules = cythonize(
["**/*.pyx"],
compiler_directives={
"binding": True, # so inspect function works properly on cythonized functions
"language_level": language_level,
}, # avoid cython warnings
) So yes, explicitly the biding is set as I look for the line I can try with the most recent Cython version and let you know the outcome. |
No changes with |
To clarify, what I tested was
and then tested it with:
That gives
Then if I do
I don't think your example that you show in the issue is quite what you actually run - for example the module and function names don't match. |
The only step that I miss explaining is that the ext_modules = cythonize(
["**/*.pyx"],
compiler_directives={
"binding": True, # so inspect function works properly on cythonized functions
"language_level": language_level,
}, # avoid cython warnings
) Then, the module is installed and imports the function from the cythonized wheel. I can create a small repository with the example and attach it to our discussion with a tox file for execution. |
I managed to pack nicely in a repository (cy_wheel_gens_tests). |
The issue is your wrapper in
This prints |
Aha, I see. I will make a better example because the issue that we are having is on pluggy verification of pytest hooks. I will investigate more and if persists I will open a new ticket. Thank you for your time. |
Please, if is possible can you try to take a look at example again ? In the same repository here. I upadted the README.md with the updates made on implementation and on the test. |
Works for me on 3.10 and 3.11:
On 3.8, 3.9 The changes in inspect that make it work right came in Python 3.10.6 and 3.11.0. (python/cpython#94050) There's no way for us to make it work on earlier versions of Python. |
Understood. Anyway, thank you once more for your time. |
Your other option would be to monkey-patch Line 140 in 07553a5
At one point Cython did this specifically for |
Describe the bug
Generators that are cythonized cannot be identified as generators when
inspect.isgeneratorfunction
is used.Code to reproduce the behaviour:
The code below is used in the package that will be cythonized:
and then used by the test
Expected behaviour
Running the same test with the
src/test_gens/impl.pyx
code in a .py file the return isTrue
, as expected.OS
Windows
Python version
3.8.4, 3.9.6, 3.10.4, 3.11.4
Cython version
3.0.0
Additional context
No response
The text was updated successfully, but these errors were encountered: