From: Robert Bradshaw Date: Sat, 2 Feb 2008 09:18:43 +0000 (-0800) Subject: does type check for extension types X-Git-Tag: 0.9.6.14~29^2~47 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=68592200c5f466acc5e7795865012bdeb9c03245;p=cython.git does type check for extension types --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 09f088c7..d8d5768c 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2617,6 +2617,9 @@ class TypecastNode(ExprNode): self.operand = self.operand.coerce_to(self.type, env) else: warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type)) + elif from_py and to_py: + if self.typecheck and self.type.is_extension_type: + self.operand = PyTypeTestNode(self.operand, self.type, env) def check_const(self): self.operand.check_const() diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 14af9c99..52729e1a 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -207,12 +207,18 @@ def p_typecast(s): s.next() base_type = p_c_base_type(s) declarator = p_c_declarator(s, empty = 1) + if s.sy == '?': + s.next() + typecheck = 1 + else: + typecheck = 0 s.expect(">") operand = p_factor(s) return ExprNodes.TypecastNode(pos, base_type = base_type, declarator = declarator, - operand = operand) + operand = operand, + typecheck = typecheck) def p_sizeof(s): # s.sy == ident "sizeof"