From 59367485d8a60a80fa5eea98302a470727c119ae Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 11 Jun 2008 14:23:59 -0700 Subject: [PATCH] Fix crash for scope=None compilation error, more strict literal char* -> int --- Cython/Compiler/ExprNodes.py | 7 ++++--- Cython/Compiler/Nodes.py | 2 ++ tests/errors/e_cmethbasematch.pyx | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) 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 """ -- 2.26.2