From 1e0453f29583ebc96fc22ded1a78d828a4ef87c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Tue, 19 Jun 2018 16:36:07 +0200 Subject: [PATCH] Improve YAML 1.2 compatibility for scientific notation Allow exponents without sign, mantissa without dot. Resolves #173 --- lib/yaml/resolver.py | 5 +++-- lib3/yaml/resolver.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/yaml/resolver.py b/lib/yaml/resolver.py index 528fbc0e..301fad2a 100644 --- a/lib/yaml/resolver.py +++ b/lib/yaml/resolver.py @@ -176,8 +176,9 @@ class Resolver(BaseResolver): Resolver.add_implicit_resolver( u'tag:yaml.org,2002:float', - re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? - |\.[0-9_]+(?:[eE][-+][0-9]+)? + re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+]?[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) |\.(?:nan|NaN|NAN))$''', re.X), diff --git a/lib3/yaml/resolver.py b/lib3/yaml/resolver.py index 02b82e73..18efe865 100644 --- a/lib3/yaml/resolver.py +++ b/lib3/yaml/resolver.py @@ -176,8 +176,9 @@ class Resolver(BaseResolver): Resolver.add_implicit_resolver( 'tag:yaml.org,2002:float', - re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? - |\.[0-9_]+(?:[eE][-+][0-9]+)? + re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+]?[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) |\.(?:nan|NaN|NAN))$''', re.X),