File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ def safe_eval(expr, namespace):
6363# * new docstring describing different functionality
6464# * looks up names from namespace
6565# * indexing syntax is allowed
66+ # * evaluates tuple() and list()
6667def simple_eval (node_or_string , namespace = None ):
6768 """
6869 Safely evaluate an expression node or a string containing a Python
@@ -111,6 +112,22 @@ def _convert(node):
111112 ):
112113 return set ()
113114
115+ # this is a deviation from literal_eval: we evaluate tuple() and list()
116+ elif (
117+ isinstance (node , ast .Call )
118+ and isinstance (node .func , ast .Name )
119+ and node .func .id == "tuple"
120+ and node .args == node .keywords == []
121+ ):
122+ return tuple ()
123+ elif (
124+ isinstance (node , ast .Call )
125+ and isinstance (node .func , ast .Name )
126+ and node .func .id == "list"
127+ and node .args == node .keywords == []
128+ ):
129+ return list ()
130+
114131 # this is a deviation from literal_eval: we allow non-literals
115132 elif isinstance (node , _name_type_nodes ):
116133 try :
You can’t perform that action at this time.
0 commit comments