Commit adc5a3ea authored by Robert Bradshaw's avatar Robert Bradshaw

Fix bug in property attribute access exposed by pure mode.

parent 1619617d
......@@ -948,15 +948,6 @@ class CVarDefNode(StatNode):
dest_scope = env
self.dest_scope = dest_scope
base_type = self.base_type.analyse(env)
# If the field is an external typedef, we cannot be sure about the type,
# so do conversion ourself rather than rely on the CPython mechanism (through
# a property; made in AnalyseDeclarationsTransform).
if (dest_scope.is_c_class_scope
and self.visibility in ('public', 'readonly')):
need_property = True
else:
need_property = False
visibility = self.visibility
for declarator in self.declarators:
......@@ -990,7 +981,6 @@ class CVarDefNode(StatNode):
"Only 'extern' C variable declaration allowed in .pxd file")
entry = dest_scope.declare_var(name, type, declarator.pos,
cname=cname, visibility=visibility, api=self.api, is_cdef=1)
entry.needs_property = need_property
class CStructOrUnionDefNode(StatNode):
......
......@@ -1600,6 +1600,10 @@ class CClassScope(ClassScope):
error(pos,
"Attribute of extension type cannot be declared %s" % visibility)
if visibility in ('public', 'readonly'):
# If the field is an external typedef, we cannot be sure about the type,
# so do conversion ourself rather than rely on the CPython mechanism (through
# a property; made in AnalyseDeclarationsTransform).
entry.needs_property = True
if name == "__weakref__":
error(pos, "Special attribute __weakref__ cannot be exposed to Python")
if not type.is_pyobject:
......@@ -1608,6 +1612,8 @@ class CClassScope(ClassScope):
type.create_from_py_utility_code(self))):
error(pos,
"C attribute of type '%s' cannot be accessed from Python" % type)
else:
entry.needs_property = False
return entry
else:
if type is unspecified_type:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment