always optimise tuple(some_list), not only for literals
authorStefan Behnel <scoder@users.berlios.de>
Tue, 15 Sep 2009 12:12:40 +0000 (14:12 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 15 Sep 2009 12:12:40 +0000 (14:12 +0200)
Cython/Compiler/Optimize.py

index 261f6c148b9f68facf4293f6f277984b540eb8db..425c7f6eff136fa95fe1bc7fe3bfdfdb0894dd9f 100644 (file)
@@ -667,8 +667,9 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform):
             return node
         if not isinstance(list_arg, (ExprNodes.ComprehensionNode,
                                      ExprNodes.ListNode)):
-            # everything else may be None => take the safe path
-            return node
+            pos_args.args[0] = ExprNodes.NoneCheckNode(
+                list_arg, "PyExc_TypeError",
+                "'NoneType' object is not iterable")
 
         return ExprNodes.PythonCapiCallNode(
             node.pos, "PyList_AsTuple", self.PyList_AsTuple_func_type,