None check for optimised dict() call
authorStefan Behnel <scoder@users.berlios.de>
Sun, 29 Mar 2009 19:46:04 +0000 (21:46 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 29 Mar 2009 19:46:04 +0000 (21:46 +0200)
Cython/Compiler/Optimize.py

index ebbf497b70fc765bd1c53e611a756a4349aeb0b8..c90af1ccee6f66f1469f2901ebb0ee6f31a3322e 100644 (file)
@@ -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
             )