enable Python methods on C types through coercion to Python objects
authorStefan Behnel <scoder@users.berlios.de>
Thu, 3 Dec 2009 12:17:39 +0000 (13:17 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 3 Dec 2009 12:17:39 +0000 (13:17 +0100)
Cython/Compiler/ExprNodes.py

index 21b3bf1cf8b3a3d4983e6342726e4ee3dd2807fe..588b379c030c54bd935101d2e3a8782bea2a67c4 100644 (file)
@@ -3010,14 +3010,14 @@ class AttributeNode(ExprNode):
         if obj_type is None:
             obj_type = self.obj.type
         self.member = self.attribute
-        if obj_type.is_pyobject:
-            self.type = py_object_type
-            self.is_py_attr = 1
-        else:
-            if not obj_type.is_error:
-                error(self.pos, 
-                    "Object of type '%s' has no attribute '%s'" %
-                    (obj_type, self.attribute))
+        self.type = py_object_type
+        self.is_py_attr = 1
+        if not obj_type.is_pyobject:
+            self.obj = self.obj.coerce_to_pyobject(env)
+            ## if not obj_type.is_error:
+            ##     error(self.pos, 
+            ##         "Object of type '%s' has no attribute '%s'" %
+            ##         (obj_type, self.attribute))
 
     def nogil_check(self, env):
         if self.is_py_attr: