summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--README.rst6
-rw-r--r--__init__.py72
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_issues.py2
-rw-r--r--reader.py4
-rw-r--r--scanner.py23
7 files changed, 56 insertions, 57 deletions
diff --git a/CHANGES b/CHANGES
index ff446b4..1d69690 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+[0, 15, 66]: 2018-09-07
+ - fix issue with fold indicating characters inserted in safe_load-ed folded strings
+ (reported by `Maximilian Hils <https://bitbucket.org/mhils/>`__).
+
[0, 15, 65]: 2018-09-07
- fix issue #232 revert to throw ParserError for unexcpected ``]``
and ``}`` instead of IndexError. (Issue reported and PR with fix
diff --git a/README.rst b/README.rst
index 2f2466a..200dd45 100644
--- a/README.rst
+++ b/README.rst
@@ -4,7 +4,7 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.65
+:version: 0.15.66
:updated: 2018-09-07
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
@@ -54,6 +54,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.66 (2018-09-07):
+ - fix issue with fold indicating characters inserted in safe_load-ed folded strings
+ (reported by `Maximilian Hils <https://bitbucket.org/mhils/>`__).
+
0.15.65 (2018-09-07):
- fix issue #232 revert to throw ParserError for unexcpected ``]``
and ``}`` instead of IndexError. (Issue reported and PR with fix
diff --git a/__init__.py b/__init__.py
index c0c17c9..9203c12 100644
--- a/__init__.py
+++ b/__init__.py
@@ -7,60 +7,60 @@ if False: # MYPY
_package_data = dict(
full_package_name='ruamel.yaml',
- version_info=(0, 15, 65),
- __version__='0.15.65',
+ version_info=(0, 15, 66),
+ __version__='0.15.66',
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',
- 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',
- ],
- lib=[],
- test="""
+ dict(
+ 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',
+ ],
+ lib=[],
+ test="""
int main(int argc, char* argv[])
{
/* prevent warning */
return 0;
}
""",
- ),
+ )
],
# 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.4',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Programming Language :: Python :: 3.7',
- '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.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ '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',
- wheels=dict(
- windows='appveyor',
- linux='libyaml-devel',
- macos='builder@macos',
- ),
+ wheels=dict(windows='appveyor', linux='libyaml-devel', macos='builder@macos'),
read_the_docs='yaml',
supported=[(2, 7), (3, 4)], # minimum
tox=dict(
diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg
index f88c2bb..5ca4e23 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.65</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.65</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.66</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.66</text></g> </svg>
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 460acf9..1737aa9 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -391,7 +391,6 @@ class TestIssues:
yaml.safe_load('{]')
def test_issue_234(self):
- import ruamel.yaml
from ruamel.yaml import YAML
inp = dedent("""\
@@ -404,7 +403,6 @@ class TestIssues:
""")
yaml = YAML(typ='safe', pure=True)
data = yaml.load(inp)
- # data = ruamel.yaml.safe_load(inp)
fold = data[0]['cmd']
print(repr(fold))
assert '\a' not in fold
diff --git a/reader.py b/reader.py
index c377024..233478b 100644
--- a/reader.py
+++ b/reader.py
@@ -168,9 +168,7 @@ class Reader(object):
ch = self.buffer[self.pointer]
self.pointer += 1
self.index += 1
- if ch == u'\n' or (
- ch == u'\r' and self.buffer[self.pointer] != u'\n'
- ):
+ if ch == u'\n' or (ch == u'\r' and self.buffer[self.pointer] != u'\n'):
self.line += 1
self.column = 0
elif ch != u'\uFEFF':
diff --git a/scanner.py b/scanner.py
index bbd77d2..c3f691f 100644
--- a/scanner.py
+++ b/scanner.py
@@ -1132,7 +1132,7 @@ class Scanner(object):
end_mark = self.reader.get_mark()
return TagToken(value, start_mark, end_mark)
- def scan_block_scalar(self, style):
+ def scan_block_scalar(self, style, rt=False):
# type: (Any) -> Any
# See the specification for details.
srp = self.reader.peek
@@ -1193,14 +1193,9 @@ class Scanner(object):
#
# This is the folding according to the specification:
- if folded and line_break == '\n':
+ if rt and folded and line_break == '\n':
chunks.append('\a')
- if (
- folded
- and line_break == '\n'
- and leading_non_space
- and srp() not in ' \t'
- ):
+ if folded and line_break == '\n' and leading_non_space and srp() not in ' \t':
if not breaks:
chunks.append(' ')
else:
@@ -1611,9 +1606,7 @@ class Scanner(object):
line_break = self.scan_line_break()
self.allow_simple_key = True
prefix = self.reader.prefix(3)
- if (prefix == '---' or prefix == '...') and srp(
- 3
- ) in _THE_END_SPACE_TAB:
+ if (prefix == '---' or prefix == '...') and srp(3) in _THE_END_SPACE_TAB:
return
breaks = []
while srp() in ' \r\n\x85\u2028\u2029':
@@ -1622,9 +1615,7 @@ class Scanner(object):
else:
breaks.append(self.scan_line_break())
prefix = self.reader.prefix(3)
- if (prefix == '---' or prefix == '...') and srp(
- 3
- ) in _THE_END_SPACE_TAB:
+ if (prefix == '---' or prefix == '...') and srp(3) in _THE_END_SPACE_TAB:
return
if line_break != '\n':
chunks.append(line_break)
@@ -1940,6 +1931,10 @@ class RoundTripScanner(Scanner):
return ch
return ""
+ def scan_block_scalar(self, style):
+ # type: (Any) -> Any
+ return Scanner.scan_block_scalar(self, style, rt=True)
+
# try:
# import psyco