From: Stefan Behnel Date: Tue, 15 Sep 2009 12:12:40 +0000 (+0200) Subject: always optimise tuple(some_list), not only for literals X-Git-Tag: 0.12.alpha0~198 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=99da1f3afd30246512f48116962474c159c37398;p=cython.git always optimise tuple(some_list), not only for literals --- 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,