Regression for no attribute '__reduce_cython__' in Cython 0.29
See original GitHub issuePlatform: Windows 10 Python Version: 3.6.7
When running a program built with PyInstaller, cdef class
types built with Cython 0.29
or later fail during extension module initialization with
AttributeError: type object '<type>' has no attribute '__reduce_cython__'
.
I can confirm that the fix in Cython 0.28.3
-2.8.6
still works.
The program works without issue when run from Python instead of the PyInstaller bundle.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
'__reduce_cython__' error in Python while importing ...
I have Anaconda and I am a Jupyter Notebook user. I am unable to troubleshoot this error. AttributeError Traceback (most recent call last)...
Read more >Type Object 'Pandas._Libs.Tslib._Tsobject' Has No Attribute ...
AttributeError: module 'pandas' has no attribute 'tslib' how to resolve this I am ... Regression for no attribute 'reducecython' in Cython 0.29 #2985....
Read more >Cython 0.26 and Python 3 - Google Groups
After upgrading to Cython 0.26 from 0.25.2, I am now getting the following error at runtime with the ... AbelianGroup' has no attribute...
Read more >Cython 0.29.14 - PyPI
The Cython compiler for writing C extensions for the Python language.
Read more >Installing Cython — Cython 3.0.0a11 documentation
Installing Cython¶. Many scientific Python distributions, such as Anaconda [Anaconda], Enthought Canopy [Canopy], and Sage [Sage], bundle Cython and no ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have a pretty simple pure-Python and Cython repro of this problem. Using Cython 0.29.13, create this file
cytest.pyx
:Then after compiling it, run:
Expected behavior is to see an
ImportError
from the attempt to import a nonexistent module. Actual behavior is that we see the__reduce_cython__
AttributeError instead, hiding the real error.This is not just a toy example, it was simplified from a real-world Django application. When importing your
INSTALLED_APPS
, Django has code to catchImportError
and try to import again, treating the final component of the dotted path as an attribute instead of a submodule. We had an ImportError in unrelated code several layers deeper in the import stack from our Cython module, and Cython (in combination with Django’s re-importing behavior) replaced the ImportError with the__reduce_cython__
AttributeError on the second try, totally hiding the real ImportError and making it very difficult to debug. (Note that the failing import doesn’t have to be directly in the Cython module, as in the simplest-case above, it can be anywhere deeper in the import stack.)Closing as duplicate of #3545.