Skip to content

Commit fa6ace5

Browse files
committed
Check binary operations during the bare-word replacement walk
1 parent e98ad59 commit fa6ace5

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎fire/parser.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def _LiteralEval(value):
8080
"""Parse value as a Python literal, or container of containers and literals.
8181
8282
First the AST of the value is checked for binary operations, which are not
83-
literals. Then the AST is updated so that bare-words are turned into strings.
84-
Then the resulting AST is evaluated as a literal or container of only
83+
literals, and updated so that bare-words are turned into strings, in a single
84+
walk. Then the resulting AST is evaluated as a literal or container of only
8585
containers and literals.
8686
8787
This allows for the YAML-like syntax {a: b} to represent the dict {'a': 'b'}
@@ -105,7 +105,6 @@ def _LiteralEval(value):
105105
if isinstance(node, ast.BinOp) and not _IsComplexLiteral(node):
106106
raise ValueError(value)
107107

108-
for node in ast.walk(root):
109108
for field, child in ast.iter_fields(node):
110109
if isinstance(child, list):
111110
for index, subchild in enumerate(child):

0 commit comments

Comments
 (0)