From 0427670ffa4fd8f70824dbf9533514f9a4daeff3 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Wed, 17 Jul 2019 09:53:27 +0200 Subject: allow dump of deepcopied data from commented YAML fixes issue #295 *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))* --- CHANGES | 13 ++++++------- README.rst | 11 +++++++++-- __init__.py | 4 ++-- _doc/_static/pypi.svg | 2 +- _test/test_issues.py | 4 ++-- error.py | 10 ++++++++++ tokens.py | 12 ++++++++++++ 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 24a099b..f0ab62d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,9 @@ -[0, 15, 99]: 2019-07-12 - - add `py.typed` to distribution, based on a PR submitted by - `Michael Crusoe - `__ - - merge PR 40 (also by Michael Crusoe) to more accurately specify - repository in the README (also reported in a misunderstood issue - some time ago) +[0, 15, 100]: 2019-07-17 + - fixing issue with dumping deep-copied data from commented YAML, by + providing both the memo parameter to __deepcopy__, and by allowing + startmarks to be compared on their content (reported by `Theofilos + Petsios + `__) [0, 15, 99]: 2019-07-12 - add `py.typed` to distribution, based on a PR submitted by diff --git a/README.rst b/README.rst index bc7c83c..fca85cc 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.99 -:updated: 2019-07-12 +:version: 0.15.100 +:updated: 2019-07-17 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/yaml :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,6 +54,13 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.15.100 (2019-07-17): + - fixing issue with dumping deep-copied data from commented YAML, by + providing both the memo parameter to __deepcopy__, and by allowing + startmarks to be compared on their content (reported by `Theofilos + Petsios + `__) + 0.15.99 (2019-07-12): - add `py.typed` to distribution, based on a PR submitted by `Michael Crusoe diff --git a/__init__.py b/__init__.py index 07827ed..48d9a03 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, 99), - __version__='0.15.99', + version_info=(0, 15, 100), + __version__='0.15.100', 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 0d4493b..7525ff0 100644 --- a/_doc/_static/pypi.svg +++ b/_doc/_static/pypi.svg @@ -1 +1 @@ - pypipypi0.15.990.15.99 + pypipypi0.15.1000.15.100 diff --git a/_test/test_issues.py b/_test/test_issues.py index 7968e74..90128dd 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -798,7 +798,7 @@ class TestIssues: yaml.dump(data, buf) assert buf.getvalue() == yamldoc - @pytest.mark.xfail(strict=True, reason='should fail pre 0.15.100', raises=AssertionError) + # @pytest.mark.xfail(strict=True, reason='should fail pre 0.15.100', raises=AssertionError) def test_issue_295(self): # deepcopy also makes a copy of the start and end mark, and these did not # have any comparison beyond their ID, which of course changed, breaking @@ -811,7 +811,7 @@ class TestIssues: # comment - l1 - l2 - + C: d: e f: diff --git a/error.py b/error.py index ab1072d..965ff7b 100644 --- a/error.py +++ b/error.py @@ -39,6 +39,16 @@ class StreamMark(object): where = ' in "%s", line %d, column %d' % (self.name, self.line + 1, self.column + 1) return where + def __eq__(self, other): + if self.line != other.line or self.column != other.column: + return False + if self.name != other.name or self.index != other.index: + return False + return True + + def __ne__(self, other): + return not self.__eq__(other) + class FileMark(StreamMark): __slots__ = () diff --git a/tokens.py b/tokens.py index d476d49..84c6847 100644 --- a/tokens.py +++ b/tokens.py @@ -270,3 +270,15 @@ class CommentToken(Token): except: # NOQA pass return 'CommentToken({})'.format(v) + + def __eq__(self, other): + if self.start_mark != other.start_mark: + return False + if self.end_mark != other.end_mark: + return False + if self.value != other.value: + return False + return True + + def __ne__(self, other): + return not self.__eq__(other) -- cgit v1.2.1