diff options
-rw-r--r-- | CHANGES | 14 | ||||
-rw-r--r-- | README.rst | 11 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/test_issues.py | 18 | ||||
-rw-r--r-- | constructor.py | 2 | ||||
-rw-r--r-- | parser.py | 7 | ||||
-rw-r--r-- | resolver.py | 2 |
8 files changed, 53 insertions, 7 deletions
@@ -1,3 +1,17 @@ +[0, 15, 93]: 2019-04-21 + - fix failure to parse empty implicit flow mapping key + - in YAML 1.1 plains scalars `y`, 'n', `Y`, and 'N' are now + correctly recognised as booleans and such strings dumped quoted + (reported by `Marcel Bollmann + <https://bitbucket.org/%7Bd8850921-9145-4ad0-ac30-64c3bd9b036d%7D/>`__) + +[0, 15, 93]: 2019-04-21 + - fix failure to parse empty implicit flow mapping key + - in YAML 1.1 plains scalars `y`, 'n', `Y`, and 'N' are now + correctly recognised as booleans and such strings dumped quoted + (reported by `Marcel Bollmann + <https://bitbucket.org/%7Bd8850921-9145-4ad0-ac30-64c3bd9b036d%7D/>`__) + [0, 15, 92]: 2019-04-16 - fix failure to parse empty implicit block mapping key (reported by `Nolan W <https://bitbucket.org/i2labs/>`__) @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.92 -:updated: 2019-04-16 +:version: 0.15.93 +:updated: 2019-04-21 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :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.93 (2019-04-21): + - fix failure to parse empty implicit flow mapping key + - in YAML 1.1 plains scalars `y`, 'n', `Y`, and 'N' are now + correctly recognised as booleans and such strings dumped quoted + (reported by `Marcel Bollmann + <https://bitbucket.org/%7Bd8850921-9145-4ad0-ac30-64c3bd9b036d%7D/>`__) + 0.15.92 (2019-04-16): - fix failure to parse empty implicit block mapping key (reported by `Nolan W <https://bitbucket.org/i2labs/>`__) diff --git a/__init__.py b/__init__.py index eb374fc..6874999 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, 92), - __version__='0.15.92', + version_info=(0, 15, 93), + __version__='0.15.93', 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 d1ffe22..e0ca818 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.92</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.92</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.93</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.93</text></g> </svg> diff --git a/_test/test_issues.py b/_test/test_issues.py index dd6910b..6392ebd 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -630,6 +630,24 @@ class TestIssues: with pytest.raises(ruamel.yaml.parser.ParserError, match='expected <block end>'): d = yaml.load(inp) + def test_issue_285(self): + from ruamel.yaml import YAML + + yaml = YAML() + inp = dedent("""\ + %YAML 1.1 + --- + - y + - n + - Y + - N + """) + a = yaml.load(inp) + assert a[0] + assert a[2] + assert not a[1] + assert not a[3] + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ diff --git a/constructor.py b/constructor.py index 4e76f18..ee605ea 100644 --- a/constructor.py +++ b/constructor.py @@ -438,6 +438,8 @@ class SafeConstructor(BaseConstructor): bool_values = { u'yes': True, u'no': False, + u'y': True, + u'n': False, u'true': True, u'false': False, u'on': True, @@ -435,7 +435,7 @@ class Parser(object): self.state = self.parse_flow_sequence_first_entry elif self.scanner.check_token(FlowMappingStartToken): pt = self.scanner.peek_token() - end_mark = self.scanner.peek_token().end_mark + end_mark = pt.end_mark event = MappingStartEvent( anchor, tag, @@ -731,6 +731,11 @@ class Parser(object): else: self.state = self.parse_flow_mapping_value return self.process_empty_scalar(token.end_mark) + elif self.resolver.processing_version > (1, 1) and self.scanner.check_token( + ValueToken + ): + self.state = self.parse_flow_mapping_value + return self.process_empty_scalar(self.scanner.peek_token().end_mark) elif not self.scanner.check_token(FlowMappingEndToken): self.states.append(self.parse_flow_mapping_empty_value) return self.parse_flow_node() diff --git a/resolver.py b/resolver.py index cadca5b..9bcbd37 100644 --- a/resolver.py +++ b/resolver.py @@ -29,7 +29,7 @@ implicit_resolvers = [ list(u'tTfF')), ([(1, 1)], u'tag:yaml.org,2002:bool', - RegExp(u'''^(?:yes|Yes|YES|no|No|NO + RegExp(u'''^(?:y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF)$''', re.X), list(u'yYnNtTfFoO')), |