Fix crash for scope=None compilation error, more strict literal char* -> int
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 11 Jun 2008 21:23:59 +0000 (14:23 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 11 Jun 2008 21:23:59 +0000 (14:23 -0700)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py
tests/errors/e_cmethbasematch.pyx

index 4a045107c4f3dce4c755df66ea4c0865ae3ece91..779474aff4b368462f972e54fc8a39c8e3001743 100644 (file)
@@ -3543,9 +3543,10 @@ class PrimaryCmpNode(ExprNode, CmpNode):
            or (self.cascade and self.cascade.has_int_operands())
     
     def coerce_chars_to_ints(self, env):
-        if self.operand1.type.is_string:
+        # coerce literal single-char strings to c chars
+        if self.operand1.type.is_string and isinstance(self.operand1, StringNode):
             self.operand1 = self.operand1.coerce_to(PyrexTypes.c_uchar_type, env)
-        if self.operand2.type.is_string:
+        if self.operand2.type.is_string and isinstance(self.operand2, StringNode):
             self.operand2 = self.operand2.coerce_to(PyrexTypes.c_uchar_type, env)
         if self.cascade:
             self.cascade.coerce_chars_to_ints(env)
@@ -3636,7 +3637,7 @@ class CascadedCmpNode(Node, CmpNode):
         return self.operand2.type.is_int
         
     def coerce_chars_to_ints(self, env):
-        if self.operand2.type.is_string:
+        if self.operand2.type.is_string and isinstance(self.operand2, StringNode):
             self.operand2 = self.operand2.coerce_to(PyrexTypes.c_uchar_type, env)
 
     def coerce_cascaded_operands_to_temp(self, env):
index 00d2ad5eb4dd9c30860688c137e60574f4c41697..1e87f7a6d9de6f908330f45f24e9f8937b2b14c0 100644 (file)
@@ -196,6 +196,8 @@ class BlockNode:
             del entries[:]
 
     def generate_py_string_decls(self, env, code):
+        if env is None:
+            return # earlier error
         entries = env.pystring_entries
         if entries:
             code.putln("")
index bc59e62bf28d8bc9bbc625b8ee1d94588f0e8b49..c3c62152cc0ec6f6e7b858aad49f79e2a1df4285 100644 (file)
@@ -6,6 +6,6 @@ cdef class D(C):
        cdef void f(self, int x):
                pass
 _ERRORS = u"""
-/Local/Projects/D/Pyrex/Source/Tests/Errors3/e_cmethbasematch.pyx:6:6: Signature does not match previous declaration
+/Local/Projects/D/Pyrex/Source/Tests/Errors3/e_cmethbasematch.pyx:6:6: Signature not compatible with previous declaration
 /Local/Projects/D/Pyrex/Source/Tests/Errors3/e_cmethbasematch.pyx:2:6: Previous declaration is here
 """