I have the following code in test.pyx
cdef class Test:
cdef long long i
def __cinit__(self, long long i):
self.i = i
def __truediv__(Test self, Test other):
return Test(self.i / other.i)
In a short python script I have this:
import test
print('Done')
When I run the script after compiling test.pyx, I get the following output along with a Windows Error dialog "python.exe has stopped working".
Done
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Note that I never call the compiled code, only import it. Also note that the crash only occurs after the python script completes execution. I've noticed that changing i from a long long to just a long causes the error to go away. Is there something basic I'm missing, or is division by a long long not always safe?
Some information about my setup if it makes a difference:
OS: Windows 7, 64-bit
Python version: 3.4.2, MSC v 1600 32 bit
Cython version: 0.22
Compiler: mingw32
EDIT: Additional Notes
- Also tested on Python 2.7.9 32 bit with the same results
- Replacing / with // gives the same result
- If all code involving division is removed (commented out, removed by the compiler, etc.), the error disappears
- The compiled code seems to be functioning properly when called even though Python crashes upon completion.