diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-08-13 14:32:00 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-08-13 14:32:00 +0200 |
commit | cbc411c5a3ecb684af18b89d8fbc41487e61d312 (patch) | |
tree | 5b923148cda1b1e4ee249b782bc6af3c2a8d008d | |
parent | 6cbc0bea18deff5ee125c37caee5e546de02b7be (diff) | |
download | ruamel.yaml-cbc411c5a3ecb684af18b89d8fbc41487e61d312.tar.gz |
issue #61: merge of merge cannot be __repr__-ed (reported by Tal Liron)0.15.28
**When this change resolves your problem, then please close this issue**
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | __init__.py | 44 | ||||
-rw-r--r-- | _test/test_issues.py | 26 | ||||
-rw-r--r-- | comments.py | 4 |
5 files changed, 56 insertions, 24 deletions
@@ -1,3 +1,6 @@ +[0, 15, 28]: 2017-08-13 + - fix issue #61: merge of merge cannot be __repr__-ed (reported by Tal Liron) + [0, 15, 27]: 2017-08-13 - fix issue 62, YAML 1.2 allows ``?`` and ``:`` in plain scalars if non-ambigious (reported by nowox) @@ -35,6 +35,9 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key +0.15.28 (2017-08-13): + - fix issue #61: merge of merge cannot be __repr__-ed (reported by Tal Liron) + 0.15.27 (2017-08-13): - fix issue 62, YAML 1.2 allows ``?`` and ``:`` in plain scalars if non-ambigious (reported by nowox) diff --git a/__init__.py b/__init__.py index ba870c9..bf5f6ab 100644 --- a/__init__.py +++ b/__init__.py @@ -7,39 +7,39 @@ if False: # MYPY _package_data = dict( full_package_name='ruamel.yaml', - version_info=(0, 15, 27), - __version__='0.15.27', + version_info=(0, 15, 28), + __version__='0.15.28', 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 entry_points=None, since=2014, - extras_require={ - ':platform_python_implementation=="CPython" and python_version<="2.7"': - ['ruamel.ordereddict'], - 'jinja2': ['ruamel.yaml.jinja2>=0.2'], - 'docs': ['ryd'], - }, + extras_require={':platform_python_implementation=="CPython" and python_version<="2.7"': [ + 'ruamel.ordereddict', + ], 'jinja2': ['ruamel.yaml.jinja2>=0.2'], 'docs': ['ryd']}, ext_modules=[dict( - name='_ruamel_yaml', + name='_ruamel_yaml', src=['ext/_ruamel_yaml.c', 'ext/api.c', 'ext/writer.c', 'ext/dumper.c', - 'ext/loader.c', 'ext/reader.c', 'ext/scanner.c', 'ext/parser.c', - 'ext/emitter.c', + 'ext/loader.c', + 'ext/reader.c', + 'ext/scanner.c', + 'ext/parser.c', + 'ext/emitter.c', ], lib=[], - # test='#include "ext/yaml.h"\n\nint main(int argc, char* argv[])\n{\nyaml_parser_t parser;\nparser = parser; /* prevent warning */\nreturn 0;\n}\n', # NOQA )], + # test='#include "ext/yaml.h"\n\nint main(int argc, char* argv[])\n{\nyaml_parser_t parser;\nparser = parser; /* prevent warning */\nreturn 0;\n}\n', # NOQA classifiers=[ - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python :: Implementation :: Jython', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Text Processing :: Markup', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Programming Language :: Python :: Implementation :: Jython', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Text Processing :: Markup', ], keywords='yaml 1.2 parser round-trip preserve quotes order config', windows_wheels=True, diff --git a/_test/test_issues.py b/_test/test_issues.py new file mode 100644 index 0000000..3260fbf --- /dev/null +++ b/_test/test_issues.py @@ -0,0 +1,26 @@ +# coding: utf-8 + +from __future__ import absolute_import, print_function, unicode_literals + + +import pytest # NOQA + +import ruamel.yaml + +from roundtrip import round_trip, round_trip_load, round_trip_dump, dedent # NOQA + + +class TestIssue61: + def test_issue_61(self): + s = dedent(""" + def1: &ANCHOR1 + key1: value1 + def: &ANCHOR + <<: *ANCHOR1 + key: value + comb: + <<: *ANCHOR + """) + data = ruamel.yaml.round_trip_load(s) + assert str(data['comb']) == str(data['def']) + assert str(data['comb']) == "ordereddict([('key', 'value'), ('key1', 'value1')])" diff --git a/comments.py b/comments.py index 9c65cf2..00f57de 100644 --- a/comments.py +++ b/comments.py @@ -851,14 +851,14 @@ class CommentedMap(ordereddict, CommentedBase): yield x, ordereddict.__getitem__(self, x) done = [] # type: List[Any] # list of processed merge items, kept for masking for merged in getattr(self, merge_attrib, []): - for x in merged[1]: + for x, v in merged[1].items(): if ordereddict.__contains__(self, x): continue for y in done: if x in y: break else: - yield x, ordereddict.__getitem__(merged[1], x) + yield x, v # ordereddict.__getitem__(merged[1], x) done.append(merged[1]) if PY2: |