emulate original error for attributes on unconvertible types
authorStefan Behnel <scoder@users.berlios.de>
Thu, 3 Dec 2009 12:48:49 +0000 (13:48 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 3 Dec 2009 12:48:49 +0000 (13:48 +0100)
Cython/Compiler/ExprNodes.py

index 5b37aee020a555c923183fccf629dc0108040715..db34be5c946669a701a06b20ce7284b98986c3c9 100644 (file)
@@ -3012,8 +3012,13 @@ class AttributeNode(ExprNode):
         self.member = 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_pyobject and not obj_type.is_error:
+            if obj_type.create_to_py_utility_code(env):
+                self.obj = self.obj.coerce_to_pyobject(env)
+            else:
+                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: