From: Robert Bradshaw Date: Wed, 11 Jun 2008 21:23:59 +0000 (-0700) Subject: Fix crash for scope=None compilation error, more strict literal char* -> int X-Git-Tag: 0.9.8rc1~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=59367485d8a60a80fa5eea98302a470727c119ae;p=cython.git Fix crash for scope=None compilation error, more strict literal char* -> int --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 4a045107..779474af 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 00d2ad5e..1e87f7a6 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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("") diff --git a/tests/errors/e_cmethbasematch.pyx b/tests/errors/e_cmethbasematch.pyx index bc59e62b..c3c62152 100644 --- a/tests/errors/e_cmethbasematch.pyx +++ b/tests/errors/e_cmethbasematch.pyx @@ -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 """