-
-
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] casting PyObject * is broken in pure python mode #4243
Comments
This is intended. There is already a ticket where this was discussed. It only applies to module globals, which are Python objects unless explicitly declare()-d as something else.
If you try the same thing inside of a function, it will probably work. I think it's ok to use a function in the documentation.
|
Hmm, yes it seems working. I did mistake when I was generelizing bug but it seems that following code snippet fails: import cython
from cython.cimports.cpython.ref import PyObject
@cython.cfunc
def foo(obj: cython.pointer(PyObject)):
pass
def main():
python_dict = {"abc": 123}
foo(cython.cast(cython.pointer(PyObject), python_dict)) compiling fails with following error:
|
@scoder can you confirm the case? If yes I will close this issue and create new one with new snippet. |
The module globals issue is: #3944 (the issue that the the annotations on globals are ignored). Your function-based version looks like a genuine bug (I think). I don't think it's necessary to create a new issue for it though |
Fixes cython#4243 (and probably a bunch more annotation bugs) AnnotationNode doesn't have any child_attrs/subexprs because it mostly doesn't want to be analyzed (it's just transformed to an evaluable string). However this means that InterpretCompilerDirectives wasn't visiting its children to set is_cython_module and so the typing was failing. I've special-cased InterpretCompilerDirectives to visit AnnotationNode fully.
Fixes cython#4243 (and probably a bunch more annotation bugs) AnnotationNode doesn't have any child_attrs/subexprs because it mostly doesn't want to be analyzed (it's just transformed to an evaluable string). However this means that InterpretCompilerDirectives wasn't visiting its children to set is_cython_module and so the typing was failing. I've special-cased InterpretCompilerDirectives to visit AnnotationNode fully.
Ok closing this bug. Thank you @da-woods ! |
Fixes #4243 (and probably a bunch more annotation bugs) AnnotationNode doesn't have any child_attrs/subexprs because it mostly doesn't want to be analyzed (it's just transformed to an evaluable string). However this means that InterpretCompilerDirectives wasn't visiting its children to set is_cython_module and so the typing was failing. I've special-cased InterpretCompilerDirectives to visit AnnotationNode fully.
Describe the bug
For some cases casting
PyObject *
is failing during compilation with error:Cannot convert 'PyObject *' to Python object
To Reproduce
Following code is compiling with no error:
But in pure python version is failing:
Expected behavior
Pure python mode should reflect cython language.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: