Commit 99da1f3a authored by Stefan Behnel's avatar Stefan Behnel

always optimise tuple(some_list), not only for literals

parent bb09b855
...@@ -667,8 +667,9 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform): ...@@ -667,8 +667,9 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform):
return node return node
if not isinstance(list_arg, (ExprNodes.ComprehensionNode, if not isinstance(list_arg, (ExprNodes.ComprehensionNode,
ExprNodes.ListNode)): ExprNodes.ListNode)):
# everything else may be None => take the safe path pos_args.args[0] = ExprNodes.NoneCheckNode(
return node list_arg, "PyExc_TypeError",
"'NoneType' object is not iterable")
return ExprNodes.PythonCapiCallNode( return ExprNodes.PythonCapiCallNode(
node.pos, "PyList_AsTuple", self.PyList_AsTuple_func_type, node.pos, "PyList_AsTuple", self.PyList_AsTuple_func_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment