summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--README.rst9
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_cyaml.py9
-rw-r--r--_test/test_spec_examples.py14
-rw-r--r--ext/emitter.c14
-rw-r--r--ext/parser.c5
8 files changed, 40 insertions, 22 deletions
diff --git a/CHANGES b/CHANGES
index 0880331..e23847e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+[0, 15, 62]: 2018-08-29
+ - C based reader/scanner & emitter now allow setting of 1.2 as YAML version.
+ ** The loading/dumping is still YAML 1.1 code**, so use the common subset of
+ YAML 1.2 and 1.1 (reported by `Ge Yang <https://bitbucket.org/yangge/>`__)
+
[0, 15, 61]: 2018-08-23
- support for round-tripping folded style scalars (initially requested
by `Johnathan Viduchinsky <https://bitbucket.org/johnathanvidu/>`__)
diff --git a/README.rst b/README.rst
index ecd8302..e577f93 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.61
-:updated: 2018-08-23
+:version: 0.15.62
+:updated: 2018-08-29
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
:pypi: https://pypi.org/project/ruamel.yaml/
@@ -54,6 +54,11 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.62 (2018-08-29):
+ - C based reader/scanner & emitter now allow setting of 1.2 as YAML version.
+ ** The loading/dumping is still YAML 1.1 code**, so use the common subset of
+ YAML 1.2 and 1.1 (reported by `Ge Yang <https://bitbucket.org/yangge/>`__)
+
0.15.61 (2018-08-23):
- support for round-tripping folded style scalars (initially requested
by `Johnathan Viduchinsky <https://bitbucket.org/johnathanvidu/>`__)
diff --git a/__init__.py b/__init__.py
index f65a31d..f5eb8b2 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, 61),
- __version__='0.15.61',
+ version_info=(0, 15, 62),
+ __version__='0.15.62',
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 63129dc..a6eb590 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.61</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.61</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.62</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.62</text></g> </svg>
diff --git a/_test/test_cyaml.py b/_test/test_cyaml.py
index f6b54d5..5ac6f31 100644
--- a/_test/test_cyaml.py
+++ b/_test/test_cyaml.py
@@ -29,7 +29,7 @@ def test_dump_cyaml():
)
assert res == 'a: 1\nb: 2\n'
-@pytest.mark.xfail(strict=True)
+
def test_load_cyaml_1_2():
# issue 155
import ruamel.yaml
@@ -43,18 +43,13 @@ def test_load_cyaml_1_2():
yaml = ruamel.yaml.YAML(typ='safe')
yaml.load(inp)
-@pytest.mark.xfail(strict=True)
+
def test_dump_cyaml_1_2():
# issue 155
import ruamel.yaml
from ruamel.yaml.compat import StringIO
assert ruamel.yaml.__with_libyaml__
- inp = dedent("""\
- %YAML 1.2
- ---
- num_epochs: 70000
- """)
yaml = ruamel.yaml.YAML(typ='safe')
yaml.version = (1, 2)
yaml.default_flow_style = False
diff --git a/_test/test_spec_examples.py b/_test/test_spec_examples.py
index 6661698..ba38585 100644
--- a/_test/test_spec_examples.py
+++ b/_test/test_spec_examples.py
@@ -87,7 +87,7 @@ def test_example_2_7():
- Mark McGwire
- Sammy Sosa
- Ken Griffey
-
+
# Team ranking
---
- Chicago Cubs
@@ -154,7 +154,7 @@ def test_example_2_11():
- Chicago cubs
:
- 2001-07-23
-
+
? [ New York Yankees,
Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
@@ -193,7 +193,7 @@ def test_example_2_13():
def test_example_2_14():
yaml = YAML()
yaml.explicit_start = True
- yam.indent(root_scalar=2) # needs to be added
+ yaml.indent(root_scalar=2) # needs to be added
yaml.round_trip("""
--- >
Mark McGwire's
@@ -209,10 +209,10 @@ def test_example_2_15():
>
Sammy Sosa completed another
fine season with great stats.
-
+
63 Home Runs
0.288 Batting Average
-
+
What a year!
""")
@@ -241,7 +241,7 @@ def test_example_2_17():
unicode: "Sosa did fine.\u263A"
control: "\b1998\t1999\t2000\n"
hex esc: "\x0d\x0a is \r\n"
-
+
single: '"Howdy!" he cried.'
quoted: ' # Not a ''comment''.'
tie-fighter: '|\-*-/|'
@@ -255,7 +255,7 @@ def test_example_2_18():
plain:
This unquoted scalar
spans many lines.
-
+
quoted: "So does this
quoted scalar.\n"
""")
diff --git a/ext/emitter.c b/ext/emitter.c
index 59d00fe..70e1c04 100644
--- a/ext/emitter.c
+++ b/ext/emitter.c
@@ -547,10 +547,16 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
* Expect DOCUMENT-START or STREAM-END.
*/
+/* assume 2 digits + . + 2 digits max and NUL*/
+#define VERSION_BUF_LEN 6
+
static int
yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
yaml_event_t *event, int first)
{
+ char version_buf[VERSION_BUF_LEN];
+ yaml_version_directive_t vdp;
+
if (event->type == YAML_DOCUMENT_START_EVENT)
{
yaml_tag_directive_t default_tag_directives[] = {
@@ -602,7 +608,10 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
implicit = 0;
if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
return 0;
- if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
+ /* if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) */
+ vdp = (yaml_version_directive_t) *event->data.document_start.version_directive;
+ snprintf(version_buf, VERSION_BUF_LEN, "%d.%d", vdp.major, vdp.minor);
+ if (!yaml_emitter_write_indicator(emitter, version_buf, 1, 0, 0))
return 0;
if (!yaml_emitter_write_indent(emitter))
return 0;
@@ -1333,7 +1342,8 @@ static int
yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
yaml_version_directive_t version_directive)
{
- if (version_directive.major != 1 || version_directive.minor != 1) {
+ if (version_directive.major != 1 || (
+ version_directive.minor != 1 && version_directive.minor != 2) ) {
return yaml_emitter_set_emitter_error(emitter,
"incompatible %YAML directive");
}
diff --git a/ext/parser.c b/ext/parser.c
index 0691d48..3aecb59 100644
--- a/ext/parser.c
+++ b/ext/parser.c
@@ -1265,7 +1265,10 @@ yaml_parser_process_directives(yaml_parser_t *parser,
goto error;
}
if (token->data.version_directive.major != 1
- || token->data.version_directive.minor != 1) {
+ || (token->data.version_directive.minor != 1
+ && token->data.version_directive.minor != 2
+ )
+ ) {
yaml_parser_set_parser_error(parser,
"found incompatible YAML document", token->start_mark);
goto error;