diff --git a/lib3/yaml/constructor.py b/lib3/yaml/constructor.py index 619acd30..d55d758a 100644 --- a/lib3/yaml/constructor.py +++ b/lib3/yaml/constructor.py @@ -279,6 +279,8 @@ def construct_yaml_float(self, node): return sign*self.inf_value elif value == '.nan': return self.nan_value + elif value == '.': + return 0.0 elif ':' in value: digits = [float(part) for part in value.split(':')] digits.reverse() diff --git a/lib3/yaml/resolver.py b/lib3/yaml/resolver.py index 013896d2..eeda44ce 100644 --- a/lib3/yaml/resolver.py +++ b/lib3/yaml/resolver.py @@ -176,7 +176,7 @@ class Resolver(BaseResolver): Resolver.add_implicit_resolver( 'tag:yaml.org,2002:float', - re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? + re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*(?:[eE][-+][0-9]+)? |\.[0-9_]+(?:[eE][-+][0-9]+)? |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]* |[-+]?\.(?:inf|Inf|INF) diff --git a/tests/data/yaml11.schema-skip b/tests/data/yaml11.schema-skip index 0fb92ef0..2d78a619 100644 --- a/tests/data/yaml11.schema-skip +++ b/tests/data/yaml11.schema-skip @@ -1,7 +1,6 @@ load: { 'Y': 1, 'y': 1, 'N': 1, 'n': 1, '!!bool Y': 1, '!!bool N': 1, '!!bool n': 1, '!!bool y': 1, - '!!float .': 1, '!!float ._', '!!str .', '.', '._', } dump: { '!!str N': 1, '!!str Y': 1, '!!str n': 1, '!!str y': 1,