summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-10-06 19:34:28 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-10-06 19:34:28 +0200
commitffaab93d8964e7fbcbc2efe3399ae128fb4c5756 (patch)
tree3f76d9322d1edfc8ca66e4bbe98cfed8c3cf7a11
parent334c992703b2093a26b59d2cac403375b568c617 (diff)
downloadruamel.yaml-ffaab93d8964e7fbcbc2efe3399ae128fb4c5756.tar.gz
fix issue #245 regression on C parsing of explicit 1.1 source0.15.72
*When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
-rw-r--r--CHANGES8
-rw-r--r--README.rst10
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/roundtrip.py4
-rw-r--r--_test/test_issues.py1
-rw-r--r--_test/test_z_data.py8
-rw-r--r--main.py8
-rw-r--r--resolver.py17
9 files changed, 42 insertions, 20 deletions
diff --git a/CHANGES b/CHANGES
index aaab1b7..cb6ee69 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+[0, 15, 72]: 2018-10-06
+ - fix regression on explicit 1.1 loading with the C based scanner/parser
+ (reported by `Tomas Vavra <https://bitbucket.org/xtomik/>`__)
+
+[0, 15, 72]: 2018-10-06
+ - fix regression on explicit 1.1 loading with the C based scanner/parser
+ (reported by `Tomas Vavra <https://bitbucket.org/xtomik/>`__)
+
[0, 15, 71]: 2018-09-26
- fix regression where handcrafted CommentedMaps could not be initiated (reported by
`Dan Helfman <https://bitbucket.org/dhelfman/>`__)
diff --git a/README.rst b/README.rst
index 5422764..f466c7f 100644
--- a/README.rst
+++ b/README.rst
@@ -4,8 +4,8 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.71
-:updated: 2018-09-26
+:version: 0.15.72
+:updated: 2018-10-06
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
:pypi: https://pypi.org/project/ruamel.yaml/
@@ -19,7 +19,7 @@ functionality will throw a warning before being changed/removed.
but new functionality is likely only to be available via the new API.
If your package uses ``ruamel.yaml`` and is not listed on PyPI, drop
-me an email, preferably with some infomormation on how you use the
+me an email, preferably with some information on how you use the
package (or a link to bitbucket/github) and I'll keep you informed
when the status of the API is stable enough to make the transition.
@@ -54,6 +54,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.72 (2018-10-06):
+ - fix regression on explicit 1.1 loading with the C based scanner/parser
+ (reported by `Tomas Vavra <https://bitbucket.org/xtomik/>`__)
+
0.15.71 (2018-09-26):
- some of the tests now live in YAML files in the
`yaml.data <https://bitbucket.org/ruamel/yaml.data>`__ repository.
diff --git a/__init__.py b/__init__.py
index 9b815db..b9a3a44 100644
--- a/__init__.py
+++ b/__init__.py
@@ -7,8 +7,8 @@ if False: # MYPY
_package_data = dict(
full_package_name='ruamel.yaml',
- version_info=(0, 15, 71),
- __version__='0.15.71',
+ version_info=(0, 15, 72),
+ __version__='0.15.72',
author='Anthon van der Neut',
author_email='a.van.der.neut@ruamel.eu',
description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA
diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg
index b5019c7..19b9de5 100644
--- a/_doc/_static/pypi.svg
+++ b/_doc/_static/pypi.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.71</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.71</text></g> </svg>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.72</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.72</text></g> </svg>
diff --git a/_test/roundtrip.py b/_test/roundtrip.py
index 8e1e66e..ee430a3 100644
--- a/_test/roundtrip.py
+++ b/_test/roundtrip.py
@@ -251,6 +251,10 @@ def save_and_run(program, base_dir=None, output=None, file_name=None, optimized=
print('running:', *cmd)
res = check_output(cmd, stderr=STDOUT, universal_newlines=True)
if output is not None:
+ if '__pypy__' in sys.builtin_module_names:
+ res = res.splitlines(True)
+ res = [line for line in res if 'no version info' not in line]
+ res = ''.join(res)
print('result: ', res, end='')
print('expected:', output, end='')
assert res == output
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 4ccbff4..51cd5f7 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -514,7 +514,6 @@ class TestIssues:
d0 = CommentedMap([('a', 'b')])
assert d0['a'] == 'b'
- @pytest.mark.xfail(strict=True, reason='regression on Yes', raises=AssertionError)
def test_issue_xxx(self):
from ruamel.yaml import YAML
inp = """
diff --git a/_test/test_z_data.py b/_test/test_z_data.py
index 35c1ded..d106a2a 100644
--- a/_test/test_z_data.py
+++ b/_test/test_z_data.py
@@ -54,9 +54,11 @@ class YAMLData(object):
return cls(constructor.construct_mapping(node))
return cls(node.value)
+
class Python(YAMLData):
yaml_tag = '!Python'
+
class Output(YAMLData):
yaml_tag = '!Output'
@@ -144,7 +146,7 @@ class TestYAMLData(object):
assert save_and_run(python.value, base_dir=tmpdir, output=data.value) == 0
- # this is executed by pytest the methods with names not starting with test_
+ # this is executed by pytest the methods with names not starting with test_
# are helpers
def test_yaml_data(self, yaml, tmpdir):
from ruamel.yaml.compat import Mapping
@@ -168,7 +170,7 @@ class TestYAMLData(object):
elif isinstance(doc, Python):
python = doc
if typ is None:
- typ = 'pyrun'
+ typ = 'python_run'
elif isinstance(doc, YAMLData):
data = doc
else:
@@ -187,7 +189,7 @@ class TestYAMLData(object):
print('output:', output.value if output is not None else output)
if typ == 'rt':
self.round_trip(data, output, yaml_version=yaml_version)
- elif typ == 'pyrun':
+ elif typ == 'python_run':
self.run_python(python, output if output is not None else data, tmpdir)
elif typ == 'load_assert':
self.load_assert(data, confirm, yaml_version=yaml_version)
diff --git a/main.py b/main.py
index 2c5c7d5..140e696 100644
--- a/main.py
+++ b/main.py
@@ -394,17 +394,17 @@ class YAML(object):
# if you just initialise the CParser, to much of resolver.py
# is actually used
rslvr = self.Resolver
- if rslvr is ruamel.yaml.resolver.VersionedResolver:
- rslvr = ruamel.yaml.resolver.Resolver
+ # if rslvr is ruamel.yaml.resolver.VersionedResolver:
+ # rslvr = ruamel.yaml.resolver.Resolver
class XLoader(self.Parser, self.Constructor, rslvr): # type: ignore
- def __init__(selfx, stream, version=None, preserve_quotes=None):
+ def __init__(selfx, stream, version=self.version, preserve_quotes=None):
# type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None # NOQA
CParser.__init__(selfx, stream)
selfx._parser = selfx._composer = selfx
self.Constructor.__init__(selfx, loader=selfx)
selfx.allow_duplicate_keys = self.allow_duplicate_keys
- rslvr.__init__(selfx, loadumper=selfx)
+ rslvr.__init__(selfx, version=version, loadumper=selfx)
self._stream = stream
loader = XLoader(stream)
diff --git a/resolver.py b/resolver.py
index 2641a54..5da1fe3 100644
--- a/resolver.py
+++ b/resolver.py
@@ -316,8 +316,10 @@ class VersionedResolver(BaseResolver):
and Yes/No/On/Off booleans.
"""
- def __init__(self, version=None, loader=None):
- # type: (Optional[VersionType], Any) -> None
+ def __init__(self, version=None, loader=None, loadumper=None):
+ # type: (Optional[VersionType], Any, Any) -> None
+ if loader is None and loadumper is not None:
+ loader = loadumper
BaseResolver.__init__(self, loader)
self._loader_version = self.get_loader_version(version)
self._version_implicit_resolver = {} # type: Dict[Any, Any]
@@ -383,10 +385,13 @@ class VersionedResolver(BaseResolver):
try:
version = self.parser.yaml_version
except AttributeError:
- if hasattr(self.loadumper, 'typ'):
- version = self.loadumper.version
- else:
- version = self.loadumper._serializer.use_version # dumping
+ try:
+ if hasattr(self.loadumper, 'typ'):
+ version = self.loadumper.version
+ else:
+ version = self.loadumper._serializer.use_version # dumping
+ except AttributeError:
+ version = None
if version is None:
version = self._loader_version
if version is None: