Revert previous fix of #303
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 26 May 2009 20:42:03 +0000 (22:42 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 26 May 2009 20:42:03 +0000 (22:42 +0200)
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py

index 4e1c860617e9d9a50bbf17d44993e334a21eeef6..0b572e7eed8d16a06dd4485d089541f7b1e7f832 100644 (file)
@@ -801,25 +801,18 @@ class CVarDefNode(StatNode):
         self.dest_scope = dest_scope
         base_type = self.base_type.analyse(env)
 
-        need_property = False
+        # 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 == 'public'
-              and base_type.is_pyobject
-              and (base_type.is_builtin_type or base_type.is_extension_type)):
-            # If the field is settable and extension type, then the CPython mechanism does
-            # not do enough type-checking for us.
-            need_property = True
-        elif (base_type.is_typedef and base_type.typedef_is_external
-              and (self.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).
+                and self.visibility == 'public' 
+                and base_type.is_pyobject 
+                and (base_type.is_builtin_type or base_type.is_extension_type)):
+            self.need_properties = []
             need_property = True
-
-        if need_property:
             visibility = 'private'
-            self.need_properties = []
         else:
+            need_property = False
             visibility = self.visibility
             
         for declarator in self.declarators:
index 1f3bf7d232383df7f34bbfc54f59195915c84c7f..36200d7414c8ffe72c07f014add32d70f22eb4a8 100644 (file)
@@ -625,12 +625,6 @@ property NAME:
         ATTR = value
     """, level='c_class')
 
-    readonly_property = TreeFragment(u"""
-property NAME:
-    def __get__(self):
-        return ATTR
-    """, level='c_class')
-    
     def __call__(self, root):
         self.env_stack = [root.scope]
         # needed to determine if a cdef var is declared after it's used.
@@ -707,7 +701,7 @@ property NAME:
             # mechanism for them. 
             stats = []
             for entry in node.need_properties:
-                property = self.create_Property(entry, node.visibility == 'readonly')
+                property = self.create_Property(entry)
                 property.analyse_declarations(node.dest_scope)
                 self.visit(property)
                 stats.append(property)
@@ -715,11 +709,8 @@ property NAME:
         else:
             return None
             
-    def create_Property(self, entry, readonly):
-        if readonly:
-            template = self.readonly_property
-        else:
-            template = self.basic_property
+    def create_Property(self, entry):
+        template = self.basic_property
         property = template.substitute({
                 u"ATTR": AttributeNode(pos=entry.pos,
                                        obj=NameNode(pos=entry.pos, name="self"),