From 99da1f3afd30246512f48116962474c159c37398 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 15 Sep 2009 14:12:40 +0200 Subject: [PATCH] always optimise tuple(some_list), not only for literals --- Cython/Compiler/Optimize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 261f6c14..425c7f6e 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -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, -- 2.26.2