Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #338 arg parsing truncates at hash #406

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions fire/parser.py
Expand Up @@ -66,7 +66,6 @@ def DefaultParseValue(value):
Returns:
The parsed value, of the type determined most appropriate.
"""
# Note: _LiteralEval will treat '#' as the start of a comment.
try:
return _LiteralEval(value)
except (SyntaxError, ValueError):
Expand Down Expand Up @@ -105,8 +104,12 @@ def _LiteralEval(value):
child[index] = _Replacement(subchild)

elif isinstance(child, ast.Name):
replacement = _Replacement(child)
node.__setattr__(field, replacement)
if isinstance(type(value), str) and not isinstance(type(value), int):
replacement = ast.Str(value)
node.__setattr__(field, replacement)
else:
replacement = _Replacement(child)
node.__setattr__(field, replacement)

# ast.literal_eval supports the following types:
# strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None
Expand Down