From a14248ffe1ec7a7cf8623732ebc24e680883fa20 Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Ortega Date: Sat, 21 Feb 2015 16:40:50 +0100 Subject: [PATCH 1/2] Fixes bug #10281 - Trailing zeros were truncated from strings --- lib/ansible/inventory/ini.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 2c05253bb3..8d00929668 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -54,7 +54,11 @@ class InventoryParser(object): def _parse_value(v): if "#" not in v: 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. # Likely a string that literal_eval does not like. We wil then just set it. except ValueError: From 2e929cf0cee26addecff9b129d1c6b82f6ea5cd8 Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Ortega Date: Sat, 21 Feb 2015 19:54:38 +0100 Subject: [PATCH 2/2] Fixes bug #10281 - Trailing zeros were truncated from strings --- lib/ansible/inventory/ini.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 8d00929668..7d3f1636d7 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -54,11 +54,11 @@ class InventoryParser(object): def _parse_value(v): if "#" not in v: try: - re = ast.literal_eval(v) - if type(re) == float: + ret = ast.literal_eval(v) + if type(ret) == float: # Do not trim floats. Eg: "1.20" to 1.2 return v - return re + return ret # Using explicit exceptions. # Likely a string that literal_eval does not like. We wil then just set it. except ValueError: