From 68592200c5f466acc5e7795865012bdeb9c03245 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 2 Feb 2008 01:18:43 -0800 Subject: [PATCH] does type check for extension types --- Cython/Compiler/ExprNodes.py | 3 +++ Cython/Compiler/Parsing.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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" -- 2.26.2