3
PYTHON setup.py build_ext --inplace
4
PYTHON -c "import classes"
5
PYTHON -c "import test_inherit"
7
######## setup.py ########
9
from Cython.Build.Dependencies import cythonize
11
from distutils.core import setup
14
ext_modules=cythonize("*.pyx"),
17
###### dummy_module.py ###########
22
###### classes.pxd ################
25
# apart from list, these are all variable sized types
26
# and Cython shouldn't trip up about the struct size
27
ctypedef class dummy_module.tpl [object PyTupleObject]:
29
ctypedef class dummy_module.lst [object PyListObject]:
31
ctypedef class types.CodeType [object PyCodeObject]:
33
# Note that bytes doesn't work here because it further
34
# the tp_basicsize to save space
36
##### classes.pyx #################
38
def check_tuple(tpl x):
39
assert isinstance(x, tuple)
42
assert isinstance(x, list)
44
def check_code(CodeType x):
46
assert isinstance(x, types.CodeType)
50
check_code(eval("lambda: None").__code__)
52
##### failed_inherit1.pyx #############
54
from classes cimport tpl
56
cdef class SuperTuple(tpl):
57
cdef int a # importing this gives an error message
59
##### failed_inherit2.pyx #############
61
from classes cimport tpl
63
cdef class SuperTuple(tpl):
64
# adding a method creates a vtab so should also fail
68
##### successful_inherit.pyx #########
70
from classes cimport lst, tpl
72
cdef class SuperList(lst):
73
cdef int a # This works OK
75
cdef class SuperTuple(tpl):
76
# This is actually OK because it doesn't add anything
79
##### test_inherit.py ################
82
import failed_inherit1
84
assert e.args[0] == "inheritance from PyVarObject types like 'tuple' not currently supported", e.args[0]
88
import failed_inherit2
90
assert e.args[0] == "inheritance from PyVarObject types like 'tuple' not currently supported", e.args[0]
94
import successful_inherit