From 8d9427cb4e323afca41f06c455b991cc8df326dd Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 29 Mar 2009 21:46:04 +0200 Subject: [PATCH] None check for optimised dict() call --- Cython/Compiler/Optimize.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index ebbf497b..c90af1cc 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -527,12 +527,15 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform): """ if len(pos_args.args) != 1: return node - if pos_args.args[0].type is not Builtin.dict_type: + dict_arg = pos_args.args[0] + if dict_arg.type is not Builtin.dict_type: return node + dict_arg = ExprNodes.NoneCheckNode( + dict_arg, "PyExc_TypeError", "'NoneType' is not iterable") return ExprNodes.PythonCapiCallNode( node.pos, "PyDict_Copy", self.PyDict_Copy_func_type, - args = pos_args.args, + args = [dict_arg], is_temp = node.is_temp ) -- 2.26.2