cython-devel
changeset 3091:1a2e04bc1395
remove dependency on structmember.h
| author | Lisandro Dalcin <dalcinl@gmail.com> |
|---|---|
| date | Thu Mar 11 17:21:13 2010 -0300 (23 months ago) |
| parents | 4f6cd5d121c6 |
| children | 3045d63c5f14 |
| files | Cython/Compiler/ModuleNode.py Cython/Compiler/Nodes.py Cython/Compiler/ParseTreeTransforms.py Cython/Compiler/PyrexTypes.py Cython/Compiler/Symtab.py Cython/Compiler/TypeSlots.py tests/compile/extpymemberdef.pyx tests/errors/cdef_members_T517.pyx tests/errors/e_extweakref.pyx tests/run/cdef_members_T517.pyx tests/run/embedsignatures.pyx tests/run/typedfieldbug_T303.pyx |
line diff
1.1 --- a/Cython/Compiler/ModuleNode.py Thu Mar 11 20:29:58 2010 +0100
1.2 +++ b/Cython/Compiler/ModuleNode.py Thu Mar 11 17:21:13 2010 -0300
1.3 @@ -426,6 +426,11 @@
1.4 code.globalstate["end"].putln("#endif /* Py_PYTHON_H */")
1.5
1.6 code.put("""
1.7 +#include <stddef.h> /* For offsetof */
1.8 +#ifndef offsetof
1.9 +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
1.10 +#endif
1.11 +
1.12 #ifndef PY_LONG_LONG
1.13 #define PY_LONG_LONG LONG_LONG
1.14 #endif
1.15 @@ -903,7 +908,6 @@
1.16 self.generate_descr_set_function(scope, code)
1.17 self.generate_property_accessors(scope, code)
1.18 self.generate_method_table(scope, code)
1.19 - self.generate_member_table(scope, code)
1.20 self.generate_getset_table(scope, code)
1.21 self.generate_typeobj_definition(full_module_name, entry, code)
1.22
1.23 @@ -1529,34 +1533,6 @@
1.24 code.putln(
1.25 "};")
1.26
1.27 - def generate_member_table(self, env, code):
1.28 - #print "ModuleNode.generate_member_table: scope =", env ###
1.29 - if env.public_attr_entries:
1.30 - code.putln("")
1.31 - code.putln(
1.32 - "static struct PyMemberDef %s[] = {" %
1.33 - env.member_table_cname)
1.34 - type = env.parent_type
1.35 - if type.typedef_flag:
1.36 - objstruct = type.objstruct_cname
1.37 - else:
1.38 - objstruct = "struct %s" % type.objstruct_cname
1.39 - for entry in env.public_attr_entries:
1.40 - type_code = entry.type.pymemberdef_typecode
1.41 - if entry.visibility == 'readonly':
1.42 - flags = "READONLY"
1.43 - else:
1.44 - flags = "0"
1.45 - code.putln('{(char *)"%s", %s, %s, %s, 0},' % (
1.46 - entry.name,
1.47 - type_code,
1.48 - "offsetof(%s, %s)" % (objstruct, entry.cname),
1.49 - flags))
1.50 - code.putln(
1.51 - "{0, 0, 0, 0, 0}")
1.52 - code.putln(
1.53 - "};")
1.54 -
1.55 def generate_getset_table(self, env, code):
1.56 if env.property_entries:
1.57 code.putln("")
2.1 --- a/Cython/Compiler/Nodes.py Thu Mar 11 20:29:58 2010 +0100
2.2 +++ b/Cython/Compiler/Nodes.py Thu Mar 11 17:21:13 2010 -0300
2.3 @@ -891,13 +891,13 @@
2.4 # declarators [CDeclaratorNode]
2.5 # in_pxd boolean
2.6 # api boolean
2.7 - # need_properties [entry]
2.8 + # properties [entry]
2.9
2.10 # decorators [cython.locals(...)] or None
2.11 # directive_locals { string : NameNode } locals defined by cython.locals(...)
2.12
2.13 child_attrs = ["base_type", "declarators"]
2.14 - need_properties = ()
2.15 + properties = ()
2.16
2.17 decorators = None
2.18 directive_locals = {}
2.19 @@ -912,15 +912,12 @@
2.20 # so do conversion ourself rather than rely on the CPython mechanism (through
2.21 # a property; made in AnalyseDeclarationsTransform).
2.22 if (dest_scope.is_c_class_scope
2.23 - and self.visibility == 'public'
2.24 - and base_type.is_pyobject
2.25 - and (base_type.is_builtin_type or base_type.is_extension_type)):
2.26 - self.need_properties = []
2.27 + and self.visibility in ('public', 'readonly')):
2.28 + self.properties = []
2.29 need_property = True
2.30 - visibility = 'private'
2.31 else:
2.32 need_property = False
2.33 - visibility = self.visibility
2.34 + visibility = self.visibility
2.35
2.36 for declarator in self.declarators:
2.37 name_declarator, type = declarator.analyse(base_type, env)
2.38 @@ -951,8 +948,7 @@
2.39 entry = dest_scope.declare_var(name, type, declarator.pos,
2.40 cname = cname, visibility = visibility, is_cdef = 1)
2.41 if need_property:
2.42 - self.need_properties.append(entry)
2.43 - entry.needs_property = 1
2.44 + self.properties.append(entry)
2.45
2.46
2.47 class CStructOrUnionDefNode(StatNode):
3.1 --- a/Cython/Compiler/ParseTreeTransforms.py Thu Mar 11 20:29:58 2010 +0100
3.2 +++ b/Cython/Compiler/ParseTreeTransforms.py Thu Mar 11 17:21:13 2010 -0300
3.3 @@ -952,6 +952,11 @@
3.4 def __set__(self, value):
3.5 ATTR = value
3.6 """, level='c_class')
3.7 + basic_property_ro = TreeFragment(u"""
3.8 +property NAME:
3.9 + def __get__(self):
3.10 + return ATTR
3.11 + """, level='c_class')
3.12
3.13 def __call__(self, root):
3.14 self.env_stack = [root.scope]
3.15 @@ -1037,12 +1042,9 @@
3.16 # to ensure all CNameDeclaratorNodes are visited.
3.17 self.visitchildren(node)
3.18
3.19 - if node.need_properties:
3.20 - # cdef public attributes may need type testing on
3.21 - # assignment, so we create a property accesss
3.22 - # mechanism for them.
3.23 + if node.properties:
3.24 stats = []
3.25 - for entry in node.need_properties:
3.26 + for entry in node.properties:
3.27 property = self.create_Property(entry)
3.28 property.analyse_declarations(node.dest_scope)
3.29 self.visit(property)
3.30 @@ -1052,13 +1054,34 @@
3.31 return None
3.32
3.33 def create_Property(self, entry):
3.34 - template = self.basic_property
3.35 + if entry.visibility == 'public':
3.36 + template = self.basic_property
3.37 + elif entry.visibility == 'readonly':
3.38 + template = self.basic_property_ro
3.39 property = template.substitute({
3.40 u"ATTR": AttributeNode(pos=entry.pos,
3.41 obj=NameNode(pos=entry.pos, name="self"),
3.42 attribute=entry.name),
3.43 }, pos=entry.pos).stats[0]
3.44 property.name = entry.name
3.45 + # ---------------------------------------
3.46 + # XXX This should go to AutoDocTransforms
3.47 + # ---------------------------------------
3.48 + if self.current_directives['embedsignature']:
3.49 + attr_name = entry.name
3.50 + type_name = entry.type.declaration_code("", for_display=1)
3.51 + default_value = ''
3.52 + if not entry.type.is_pyobject:
3.53 + type_name = "'%s'" % type_name
3.54 + elif entry.type.is_extension_type:
3.55 + type_name = entry.type.module_name + '.' + type_name
3.56 + if entry.init is not None:
3.57 + default_value = ' = ' + entry.init
3.58 + elif entry.init_to_none:
3.59 + default_value = ' = ' + repr(None)
3.60 + docstring = attr_name + ': ' + type_name + default_value
3.61 + property.doc = EncodedString(docstring)
3.62 + # ---------------------------------------
3.63 return property
3.64
3.65 class AnalyseExpressionsTransform(CythonTransform):
4.1 --- a/Cython/Compiler/PyrexTypes.py Thu Mar 11 20:29:58 2010 +0100
4.2 +++ b/Cython/Compiler/PyrexTypes.py Thu Mar 11 17:21:13 2010 -0300
4.3 @@ -56,7 +56,6 @@
4.4 # is_buffer boolean Is buffer access type
4.5 # has_attributes boolean Has C dot-selectable attributes
4.6 # default_value string Initial value
4.7 - # pymemberdef_typecode string Type code for PyMemberDef struct
4.8 #
4.9 # declaration_code(entity_code,
4.10 # for_display = 0, dll_linkage = None, pyrex = 0)
4.11 @@ -109,7 +108,6 @@
4.12 is_buffer = 0
4.13 has_attributes = 0
4.14 default_value = ""
4.15 - pymemberdef_typecode = None
4.16
4.17 def resolve(self):
4.18 # If a typedef, returns the base type.
4.19 @@ -198,18 +196,6 @@
4.20 self.typedef_cname = cname
4.21 self.typedef_base_type = base_type
4.22 self.typedef_is_external = is_external
4.23 - # Make typecodes in external typedefs use typesize-neutral macros
4.24 - if is_external:
4.25 - typecode = None
4.26 - if base_type.is_int:
4.27 - if base_type.signed == 0:
4.28 - typecode = "__Pyx_T_UNSIGNED_INT"
4.29 - else:
4.30 - typecode = "__Pyx_T_SIGNED_INT"
4.31 - elif base_type.is_float and not rank_to_type_name[base_type.rank] == "long double":
4.32 - typecode = "__Pyx_T_FLOATING"
4.33 - if typecode:
4.34 - self.pymemberdef_typecode = "%s(%s)" % (typecode, cname)
4.35
4.36 def resolve(self):
4.37 return self.typedef_base_type.resolve()
4.38 @@ -349,7 +335,6 @@
4.39 name = "object"
4.40 is_pyobject = 1
4.41 default_value = "0"
4.42 - pymemberdef_typecode = "T_OBJECT"
4.43 buffer_defaults = None
4.44 is_extern = False
4.45 is_subclassed = False
4.46 @@ -618,10 +603,9 @@
4.47
4.48 sign_words = ("unsigned ", "", "signed ")
4.49
4.50 - def __init__(self, rank, signed = 1, pymemberdef_typecode = None):
4.51 + def __init__(self, rank, signed = 1):
4.52 self.rank = rank
4.53 self.signed = signed
4.54 - self.pymemberdef_typecode = pymemberdef_typecode
4.55
4.56 def sign_and_name(self):
4.57 s = self.sign_words[self.signed]
4.58 @@ -787,8 +771,8 @@
4.59 from_py_function = "__Pyx_PyInt_AsInt"
4.60 exception_value = -1
4.61
4.62 - def __init__(self, rank, signed, pymemberdef_typecode = None, is_returncode = 0):
4.63 - CNumericType.__init__(self, rank, signed, pymemberdef_typecode)
4.64 + def __init__(self, rank, signed, is_returncode = 0):
4.65 + CNumericType.__init__(self, rank, signed)
4.66 self.is_returncode = is_returncode
4.67 if self.from_py_function == "__Pyx_PyInt_AsInt":
4.68 self.from_py_function = self.get_type_conversion()
4.69 @@ -887,8 +871,8 @@
4.70
4.71 exception_value = -1
4.72
4.73 - def __init__(self, rank, pymemberdef_typecode = None, math_h_modifier = ''):
4.74 - CNumericType.__init__(self, rank, 1, pymemberdef_typecode)
4.75 + def __init__(self, rank, math_h_modifier = ''):
4.76 + CNumericType.__init__(self, rank, 1)
4.77 self.math_h_modifier = math_h_modifier
4.78
4.79 def assignable_from_resolved_type(self, src_type):
4.80 @@ -1988,7 +1972,6 @@
4.81 class CUTF8CharArrayType(CStringType, CArrayType):
4.82 # C 'char []' type.
4.83
4.84 - pymemberdef_typecode = "T_STRING_INPLACE"
4.85 is_unicode = 1
4.86
4.87 to_py_function = "PyUnicode_DecodeUTF8"
4.88 @@ -2000,8 +1983,6 @@
4.89 class CCharArrayType(CStringType, CArrayType):
4.90 # C 'char []' type.
4.91
4.92 - pymemberdef_typecode = "T_STRING_INPLACE"
4.93 -
4.94 def __init__(self, size):
4.95 CArrayType.__init__(self, c_char_type, size)
4.96
4.97 @@ -2009,8 +1990,6 @@
4.98 class CCharPtrType(CStringType, CPtrType):
4.99 # C 'char *' type.
4.100
4.101 - pymemberdef_typecode = "T_STRING"
4.102 -
4.103 def __init__(self):
4.104 CPtrType.__init__(self, c_char_type)
4.105
4.106 @@ -2018,8 +1997,6 @@
4.107 class CUCharPtrType(CStringType, CPtrType):
4.108 # C 'unsigned char *' type.
4.109
4.110 - pymemberdef_typecode = "T_STRING"
4.111 -
4.112 to_py_function = "__Pyx_PyBytes_FromUString"
4.113 from_py_function = "__Pyx_PyBytes_AsUString"
4.114
4.115 @@ -2085,30 +2062,30 @@
4.116 c_void_ptr_type = CPtrType(c_void_type)
4.117 c_void_ptr_ptr_type = CPtrType(c_void_ptr_type)
4.118
4.119 -c_uchar_type = CIntType(0, 0, "T_UBYTE")
4.120 -c_ushort_type = CIntType(1, 0, "T_USHORT")
4.121 -c_uint_type = CUIntType(2, 0, "T_UINT")
4.122 -c_ulong_type = CULongType(3, 0, "T_ULONG")
4.123 -c_ulonglong_type = CULongLongType(6, 0, "T_ULONGLONG")
4.124 +c_uchar_type = CIntType(0, 0)
4.125 +c_ushort_type = CIntType(1, 0)
4.126 +c_uint_type = CUIntType(2, 0)
4.127 +c_ulong_type = CULongType(3, 0)
4.128 +c_ulonglong_type = CULongLongType(6, 0)
4.129
4.130 -c_char_type = CIntType(0, 1, "T_CHAR")
4.131 -c_short_type = CIntType(1, 1, "T_SHORT")
4.132 -c_int_type = CIntType(2, 1, "T_INT")
4.133 -c_long_type = CLongType(3, 1, "T_LONG")
4.134 -c_longlong_type = CLongLongType(6, 1, "T_LONGLONG")
4.135 -c_bint_type = CBIntType(2, 1, "T_INT")
4.136 +c_char_type = CIntType(0, 1)
4.137 +c_short_type = CIntType(1, 1)
4.138 +c_int_type = CIntType(2, 1)
4.139 +c_long_type = CLongType(3, 1)
4.140 +c_longlong_type = CLongLongType(6, 1)
4.141 +c_bint_type = CBIntType(2, 1)
4.142
4.143 -c_schar_type = CIntType(0, 2, "T_CHAR")
4.144 -c_sshort_type = CIntType(1, 2, "T_SHORT")
4.145 -c_sint_type = CIntType(2, 2, "T_INT")
4.146 -c_slong_type = CLongType(3, 2, "T_LONG")
4.147 -c_slonglong_type = CLongLongType(6, 2, "T_LONGLONG")
4.148 +c_schar_type = CIntType(0, 2)
4.149 +c_sshort_type = CIntType(1, 2)
4.150 +c_sint_type = CIntType(2, 2)
4.151 +c_slong_type = CLongType(3, 2)
4.152 +c_slonglong_type = CLongLongType(6, 2)
4.153
4.154 -c_py_ssize_t_type = CPySSizeTType(4, 2, "T_PYSSIZET")
4.155 -c_size_t_type = CSizeTType(5, 0, "T_SIZET")
4.156 +c_py_ssize_t_type = CPySSizeTType(4, 2)
4.157 +c_size_t_type = CSizeTType(5, 0)
4.158
4.159 -c_float_type = CFloatType(7, "T_FLOAT", math_h_modifier='f')
4.160 -c_double_type = CFloatType(8, "T_DOUBLE")
4.161 +c_float_type = CFloatType(7, math_h_modifier='f')
4.162 +c_double_type = CFloatType(8)
4.163 c_longdouble_type = CFloatType(9, math_h_modifier='l')
4.164
4.165 c_double_complex_type = CComplexType(c_double_type)
4.166 @@ -2123,7 +2100,7 @@
4.167 c_py_ssize_t_ptr_type = CPtrType(c_py_ssize_t_type)
4.168 c_size_t_ptr_type = CPtrType(c_size_t_type)
4.169
4.170 -c_returncode_type = CIntType(2, 1, "T_INT", is_returncode = 1)
4.171 +c_returncode_type = CIntType(2, 1, is_returncode = 1)
4.172
4.173 c_anon_enum_type = CAnonEnumType(-1, 1)
4.174
4.175 @@ -2492,68 +2469,6 @@
4.176 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
4.177 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
4.178
4.179 -#if !defined(T_PYSSIZET)
4.180 -#if PY_VERSION_HEX < 0x02050000
4.181 -#define T_PYSSIZET T_INT
4.182 -#elif !defined(T_LONGLONG)
4.183 -#define T_PYSSIZET \\
4.184 - ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \\
4.185 - ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
4.186 -#else
4.187 -#define T_PYSSIZET \\
4.188 - ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \\
4.189 - ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : \\
4.190 - ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
4.191 -#endif
4.192 -#endif
4.193 -
4.194 -
4.195 -#if !defined(T_ULONGLONG)
4.196 -#define __Pyx_T_UNSIGNED_INT(x) \\
4.197 - ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \\
4.198 - ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \\
4.199 - ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \\
4.200 - ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : -1))))
4.201 -#else
4.202 -#define __Pyx_T_UNSIGNED_INT(x) \\
4.203 - ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \\
4.204 - ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \\
4.205 - ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \\
4.206 - ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : \\
4.207 - ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
4.208 -#endif
4.209 -#if !defined(T_LONGLONG)
4.210 -#define __Pyx_T_SIGNED_INT(x) \\
4.211 - ((sizeof(x) == sizeof(char)) ? T_BYTE : \\
4.212 - ((sizeof(x) == sizeof(short)) ? T_SHORT : \\
4.213 - ((sizeof(x) == sizeof(int)) ? T_INT : \\
4.214 - ((sizeof(x) == sizeof(long)) ? T_LONG : -1))))
4.215 -#else
4.216 -#define __Pyx_T_SIGNED_INT(x) \\
4.217 - ((sizeof(x) == sizeof(char)) ? T_BYTE : \\
4.218 - ((sizeof(x) == sizeof(short)) ? T_SHORT : \\
4.219 - ((sizeof(x) == sizeof(int)) ? T_INT : \\
4.220 - ((sizeof(x) == sizeof(long)) ? T_LONG : \\
4.221 - ((sizeof(x) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))))
4.222 -#endif
4.223 -
4.224 -#define __Pyx_T_FLOATING(x) \\
4.225 - ((sizeof(x) == sizeof(float)) ? T_FLOAT : \\
4.226 - ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
4.227 -
4.228 -#if !defined(T_SIZET)
4.229 -#if !defined(T_ULONGLONG)
4.230 -#define T_SIZET \\
4.231 - ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \\
4.232 - ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
4.233 -#else
4.234 -#define T_SIZET \\
4.235 - ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \\
4.236 - ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : \\
4.237 - ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
4.238 -#endif
4.239 -#endif
4.240 -
4.241 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
4.242 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
4.243 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
5.1 --- a/Cython/Compiler/Symtab.py Thu Mar 11 20:29:58 2010 +0100
5.2 +++ b/Cython/Compiler/Symtab.py Thu Mar 11 17:21:13 2010 -0300
5.3 @@ -791,7 +791,7 @@
5.4 self.doc_cname = Naming.moddoc_cname
5.5 self.utility_code_list = []
5.6 self.module_entries = {}
5.7 - self.python_include_files = ["Python.h", "structmember.h"]
5.8 + self.python_include_files = ["Python.h"]
5.9 self.include_files = []
5.10 self.type_names = dict(outer_scope.type_names)
5.11 self.pxd_file_loaded = 0
5.12 @@ -1321,10 +1321,8 @@
5.13 # #typeobj_cname string or None
5.14 # #objstruct_cname string
5.15 # method_table_cname string
5.16 - # member_table_cname string
5.17 # getset_table_cname string
5.18 # has_pyobject_attrs boolean Any PyObject attributes?
5.19 - # public_attr_entries boolean public/readonly attrs
5.20 # property_entries [Entry]
5.21 # defined boolean Defined in .pxd file
5.22 # implemented boolean Defined in .pyx file
5.23 @@ -1336,10 +1334,8 @@
5.24 ClassScope.__init__(self, name, outer_scope)
5.25 if visibility != 'extern':
5.26 self.method_table_cname = outer_scope.mangle(Naming.methtab_prefix, name)
5.27 - self.member_table_cname = outer_scope.mangle(Naming.memtab_prefix, name)
5.28 self.getset_table_cname = outer_scope.mangle(Naming.gstab_prefix, name)
5.29 self.has_pyobject_attrs = 0
5.30 - self.public_attr_entries = []
5.31 self.property_entries = []
5.32 self.inherited_var_entries = []
5.33 self.defined = 0
5.34 @@ -1380,16 +1376,14 @@
5.35 error(pos,
5.36 "Attribute of extension type cannot be declared %s" % visibility)
5.37 if visibility in ('public', 'readonly'):
5.38 - if type.pymemberdef_typecode:
5.39 - self.public_attr_entries.append(entry)
5.40 - if name == "__weakref__":
5.41 - error(pos, "Special attribute __weakref__ cannot be exposed to Python")
5.42 - else:
5.43 - error(pos,
5.44 - "C attribute of type '%s' cannot be accessed from Python" % type)
5.45 - if visibility == 'public' and type.is_extension_type:
5.46 - error(pos,
5.47 - "Non-generic Python attribute cannot be exposed for writing from Python")
5.48 + if name == "__weakref__":
5.49 + error(pos, "Special attribute __weakref__ cannot be exposed to Python")
5.50 + if not type.is_pyobject:
5.51 + if (not type.create_to_py_utility_code(self) or
5.52 + (visibility=='public' and not
5.53 + type.create_from_py_utility_code(self))):
5.54 + error(pos,
5.55 + "C attribute of type '%s' cannot be accessed from Python" % type)
5.56 return entry
5.57 else:
5.58 if type is unspecified_type:
6.1 --- a/Cython/Compiler/TypeSlots.py Thu Mar 11 20:29:58 2010 +0100
6.2 +++ b/Cython/Compiler/TypeSlots.py Thu Mar 11 17:21:13 2010 -0300
6.3 @@ -370,10 +370,7 @@
6.4 # Slot descriptor for the table of Python-accessible attributes.
6.5
6.6 def slot_code(self, scope):
6.7 - if scope.public_attr_entries:
6.8 - return scope.member_table_cname
6.9 - else:
6.10 - return "0"
6.11 + return "0"
6.12
6.13
6.14 class GetSetSlot(SlotDescriptor):
7.1 --- a/tests/compile/extpymemberdef.pyx Thu Mar 11 20:29:58 2010 +0100
7.2 +++ b/tests/compile/extpymemberdef.pyx Thu Mar 11 17:21:13 2010 -0300
7.3 @@ -8,7 +8,7 @@
7.4 cdef public float f
7.5 cdef public double d
7.6 cdef public char *s
7.7 - cdef public char a[42]
7.8 + cdef readonly char a[42]
7.9 cdef public object o
7.10 cdef readonly int r
7.11 cdef readonly Spam e
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/tests/errors/cdef_members_T517.pyx Thu Mar 11 17:21:13 2010 -0300
8.3 @@ -0,0 +1,26 @@
8.4 +ctypedef void* VoidP
8.5 +
8.6 +cdef class Spam:
8.7 + cdef VoidP vp0
8.8 + cdef readonly VoidP vp2
8.9 + cdef public VoidP vp1
8.10 +
8.11 +ctypedef struct Foo:
8.12 + int i
8.13 +
8.14 +cdef class Bar:
8.15 + cdef Foo foo0
8.16 + cdef readonly Foo foo2
8.17 + cdef public Foo foo1
8.18 + pass
8.19 +
8.20 +_ERRORS = u"""
8.21 +5:24: C attribute of type 'VoidP' cannot be accessed from Python
8.22 +5:24: Cannot convert 'VoidP' to Python object
8.23 +6:24: C attribute of type 'VoidP' cannot be accessed from Python
8.24 +6:24: Cannot convert 'VoidP' to Python object
8.25 +6:24: Cannot convert Python object to 'VoidP'
8.26 +14:22: C attribute of type 'Foo' cannot be accessed from Python
8.27 +14:22: Cannot convert Python object to 'Foo'
8.28 +"""
8.29 +
9.1 --- a/tests/errors/e_extweakref.pyx Thu Mar 11 20:29:58 2010 +0100
9.2 +++ b/tests/errors/e_extweakref.pyx Thu Mar 11 17:21:13 2010 -0300
9.3 @@ -13,7 +13,10 @@
9.4 x = c.__weakref__
9.5 c.__weakref__ = x
9.6 _ERRORS = u"""
9.7 +5:20: Illegal use of special attribute __weakref__
9.8 +5:20: Illegal use of special attribute __weakref__
9.9 5:20: Special attribute __weakref__ cannot be exposed to Python
9.10 +8:22: Illegal use of special attribute __weakref__
9.11 8:22: Special attribute __weakref__ cannot be exposed to Python
9.12 13:6: Illegal use of special attribute __weakref__
9.13 14:2: Illegal use of special attribute __weakref__
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/tests/run/cdef_members_T517.pyx Thu Mar 11 17:21:13 2010 -0300
10.3 @@ -0,0 +1,134 @@
10.4 +#cython: embedsignature=True
10.5 +__doc__ = u"""
10.6 +>>> a = A()
10.7 +>>> a.h = 7
10.8 +>>> a.i = 127
10.9 +>>> a.l = 255
10.10 +>>> a.q = 255
10.11 +>>> a.f = 1.0/2.0
10.12 +>>> a.d = 1/2.0 + 1/4.0
10.13 +>>> a.g = 1/2.0 + 1/4.0 + 1/8.0
10.14 +>>> a.Zf = 1+2j
10.15 +>>> a.Zd = 3+4j
10.16 +>>> a.Zg = 5+6j
10.17 +
10.18 +>>> a.h, a.i, a.l
10.19 +(7, 127, 255)
10.20 +>>> a.ro_h, a.ro_i, a.ro_l
10.21 +(7, 127, 255)
10.22 +>>> a.f, a.d, a.g
10.23 +(0.5, 0.75, 0.875)
10.24 +>>> a.ro_f, a.ro_d, a.ro_g
10.25 +(0.5, 0.75, 0.875)
10.26 +>>> a.Zf, a.Zd, a.Zg
10.27 +((1+2j), (3+4j), (5+6j))
10.28 +>>> a.ro_Zf, a.ro_Zd, a.ro_Zg
10.29 +((1+2j), (3+4j), (5+6j))
10.30 +
10.31 +>>> b = B()
10.32 +>>> b.a0 #doctest: +ELLIPSIS
10.33 +Traceback (most recent call last):
10.34 + ...
10.35 +AttributeError: ...
10.36 +>>> b.b0 #doctest: +ELLIPSIS
10.37 +Traceback (most recent call last):
10.38 + ...
10.39 +AttributeError: ...
10.40 +>>> b.c0 #doctest: +ELLIPSIS
10.41 +Traceback (most recent call last):
10.42 + ...
10.43 +AttributeError: ...
10.44 +
10.45 +>>> isinstance(b.a1, type(None))
10.46 +True
10.47 +>>> isinstance(b.a2, type(None))
10.48 +True
10.49 +>>> isinstance(b.b1, list)
10.50 +True
10.51 +>>> isinstance(b.b2, list)
10.52 +True
10.53 +>>> isinstance(b.c1, A)
10.54 +True
10.55 +>>> isinstance(b.c2, A)
10.56 +True
10.57 +
10.58 +>>> b.a1 = a
10.59 +>>> b.a1 is not b.a2
10.60 +True
10.61 +
10.62 +>>> b.b1 = 1 #doctest: +ELLIPSIS
10.63 +Traceback (most recent call last):
10.64 + ...
10.65 +TypeError: ...
10.66 +>>> b.c1 = 1 #doctest: +ELLIPSIS
10.67 +Traceback (most recent call last):
10.68 + ...
10.69 +TypeError: ...
10.70 +>>> b.a2 = None #doctest: +ELLIPSIS
10.71 +Traceback (most recent call last):
10.72 + ...
10.73 +AttributeError: ...
10.74 +>>> b.b2 = [] #doctest: +ELLIPSIS
10.75 +Traceback (most recent call last):
10.76 + ...
10.77 +AttributeError: ...
10.78 +>>> b.c2 = A() #doctest: +ELLIPSIS
10.79 +Traceback (most recent call last):
10.80 + ...
10.81 +AttributeError: ...
10.82 +"""
10.83 +
10.84 +cdef class A:
10.85 +
10.86 + cdef public short h
10.87 + cdef public int i
10.88 + cdef public long l
10.89 + cdef public long long q
10.90 + cdef public float f
10.91 + cdef public double d
10.92 + cdef public long double g
10.93 + cdef public float complex Zf
10.94 + cdef public double complex Zd
10.95 + cdef public long double complex Zg
10.96 +
10.97 + cdef readonly short ro_h
10.98 + cdef readonly int ro_i
10.99 + cdef readonly long ro_l
10.100 + cdef readonly long long ro_q
10.101 + cdef readonly float ro_f
10.102 + cdef readonly double ro_d
10.103 + cdef readonly long double ro_g
10.104 + cdef readonly float complex ro_Zf
10.105 + cdef readonly double complex ro_Zd
10.106 + cdef readonly long double complex ro_Zg
10.107 +
10.108 + def __cinit__(self):
10.109 + self.ro_h = 7
10.110 + self.ro_i = 127
10.111 + self.ro_l = 255
10.112 + self.ro_q = 255
10.113 + self.ro_f = 1.0/2.0
10.114 + self.ro_d = 1/2.0 + 1/4.0
10.115 + self.ro_g = 1/2.0 + 1/4.0 + 1/8.0
10.116 + self.ro_Zf = 1+2j
10.117 + self.ro_Zd = 3+4j
10.118 + self.ro_Zg = 5+6j
10.119 +
10.120 +
10.121 +cdef class B:
10.122 +
10.123 + cdef object a0
10.124 + cdef public object a1
10.125 + cdef readonly object a2
10.126 +
10.127 + cdef list b0
10.128 + cdef public list b1
10.129 + cdef readonly list b2
10.130 +
10.131 + cdef A c0
10.132 + cdef public A c1
10.133 + cdef readonly A c2
10.134 +
10.135 + def __cinit__(self):
10.136 + self.b0 = self.b1 = self.b2 = []
10.137 + self.c0 = self.c1 = self.c2 = A()
11.1 --- a/tests/run/embedsignatures.pyx Thu Mar 11 20:29:58 2010 +0100
11.2 +++ b/tests/run/embedsignatures.pyx Thu Mar 11 17:21:13 2010 -0300
11.3 @@ -5,6 +5,15 @@
11.4 >>> print (Ext.__doc__)
11.5 Ext(a, b, c=None)
11.6
11.7 + >>> print (Ext.attr0.__doc__)
11.8 + attr0: 'int'
11.9 + >>> print (Ext.attr1.__doc__)
11.10 + attr1: object
11.11 + >>> print (Ext.attr2.__doc__)
11.12 + attr2: list
11.13 + >>> print (Ext.attr3.__doc__)
11.14 + attr3: embedsignatures.Ext
11.15 +
11.16 >>> print (Ext.a.__doc__)
11.17 Ext.a(self)
11.18
11.19 @@ -145,6 +154,11 @@
11.20
11.21 cdef class Ext:
11.22
11.23 + cdef public int attr0
11.24 + cdef public attr1
11.25 + cdef public list attr2
11.26 + cdef public Ext attr3
11.27 +
11.28 def __init__(self, a, b, c=None):
11.29 pass
11.30
12.1 --- a/tests/run/typedfieldbug_T303.pyx Thu Mar 11 20:29:58 2010 +0100
12.2 +++ b/tests/run/typedfieldbug_T303.pyx Thu Mar 11 17:21:13 2010 -0300
12.3 @@ -1,12 +1,12 @@
12.4 __doc__ = """
12.5 ->>> readonly()
12.6 +>>> readonly() #doctest: +ELLIPSIS
12.7 Traceback (most recent call last):
12.8 -...
12.9 -TypeError: readonly attribute
12.10 + ...
12.11 +TypeError: ...
12.12 """
12.13
12.14 import sys
12.15 -if sys.version_info[0] >= 3:
12.16 +if sys.version_info[0:2] >= (2,4):
12.17 __doc__ = __doc__.replace(u'TypeError:', u'AttributeError:')
12.18
12.19
12.20 @@ -51,9 +51,7 @@
12.21 def longdouble_access():
12.22 """
12.23 >>> longdouble_access()
12.24 - Traceback (most recent call last):
12.25 - ...
12.26 - SystemError: bad memberdescr type
12.27 + 42.0
12.28 """
12.29 cdef object c = MyClass()
12.30 print c.float_isreally_longdouble
