Attempt to fix disappearence of conversion errors (introduced by b8850487f853)
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 14 May 2009 15:46:40 +0000 (17:46 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 14 May 2009 15:46:40 +0000 (17:46 +0200)
Cython/Compiler/ExprNodes.py
Cython/Compiler/PyrexTypes.py
tests/errors/e_ass.pyx

index fc608b1d1ed05897fafcd64680c92f594673f340..b0c7e7ac37f529a82d8936c8fb0bb5299cdb7ae5 100644 (file)
@@ -5177,7 +5177,7 @@ class CoerceToPyTypeNode(CoercionNode):
         self.type = py_object_type
         self.gil_check(env)
         self.is_temp = 1
-        if not arg.type.to_py_function or not arg.type.create_to_py_utility_code(env):
+        if not arg.type.create_to_py_utility_code(env):
             error(arg.pos,
                 "Cannot convert '%s' to Python object" % arg.type)
         
@@ -5215,7 +5215,7 @@ class CoerceFromPyTypeNode(CoercionNode):
         CoercionNode.__init__(self, arg)
         self.type = result_type
         self.is_temp = 1
-        if not result_type.from_py_function and not result_type.create_from_py_utility_code(env):
+        if not result_type.create_from_py_utility_code(env):
             error(arg.pos,
                 "Cannot convert Python object to '%s'" % result_type)
         if self.type.is_string and self.arg.is_ephemeral():
index 57c20341dfe0b2f138a95b85a6f25295ada90fe5..17e4cf597efae036685900e26f19a27a63d73a1a 100644 (file)
@@ -445,10 +445,10 @@ class CType(PyrexType):
     exception_check = 1
 
     def create_to_py_utility_code(self, env):
-        return True
+        return self.to_py_function is not None
         
     def create_from_py_utility_code(self, env):
-        return True
+        return self.from_py_function is not None
         
     def error_condition(self, result_code):
         conds = []
index 10b11c30fc9d78fd8201a08a5906df279a39cc98..a49015db86b60935c57ab81902a464898c84b6bb 100644 (file)
@@ -4,7 +4,11 @@ cdef void foo(obj):
        cdef int *p2
        i1 = p1 # error
        p2 = obj # error
+
+       obj = p2 # error
+       
 _ERRORS = u"""
 5:16: Cannot assign type 'char *' to 'int'
 6:17: Cannot convert Python object to 'int *'
+8:17: Cannot convert 'int *' to Python object
 """