1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixes bug #10281 - Trailing zeros were truncated from strings

This commit is contained in:
Alvaro Lopez Ortega 2015-02-21 16:40:50 +01:00
parent 1cb47c807e
commit a14248ffe1

View file

@ -54,7 +54,11 @@ class InventoryParser(object):
def _parse_value(v): def _parse_value(v):
if "#" not in v: if "#" not in v:
try: try:
return ast.literal_eval(v) re = ast.literal_eval(v)
if type(re) == float:
# Do not trim floats. Eg: "1.20" to 1.2
return v
return re
# Using explicit exceptions. # Using explicit exceptions.
# Likely a string that literal_eval does not like. We wil then just set it. # Likely a string that literal_eval does not like. We wil then just set it.
except ValueError: except ValueError: