summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-06-17 16:23:11 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-06-17 16:23:11 +0200
commit9f2076c62cc42fe572336d92a5a4d71c21eec3bd (patch)
tree50b7ff8999350d590deaa007b257ca04d2f5b359
parentd6a64263556f471f9b3fa3cdbff032bc46c8888e (diff)
downloadruamel.yaml-9f2076c62cc42fe572336d92a5a4d71c21eec3bd.tar.gz
fixes issue #201: decoding Unicode
*When this change indeed resolves your problem, please **Close** this issue*. *(You can do so usingthe WorkFlow pull-down (close to the top right of this page)*
-rw-r--r--README.rst4
-rw-r--r--__init__.py4
-rw-r--r--_test/test_tag.py10
-rw-r--r--scanner.py2
4 files changed, 15 insertions, 5 deletions
diff --git a/README.rst b/README.rst
index d7eb0d7..cf491f6 100644
--- a/README.rst
+++ b/README.rst
@@ -35,6 +35,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+NEXT:
+ - fixes issue #201: decoding unicode escaped tags on Python2, reported
+ by `Dan Abolafia <https://bitbucket.org/danabo/>`__
+
0.15.39 (2018-06-17):
- merge PR27 improving package startup time (and loading when regexp not
actually used), provided by
diff --git a/__init__.py b/__init__.py
index 0474160..ebebc96 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, 39),
- __version__='0.15.39',
+ version_info=(0, 15, 40, 'dev'),
+ __version__='0.15.40.dev',
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/_test/test_tag.py b/_test/test_tag.py
index 2117ff4..247014b 100644
--- a/_test/test_tag.py
+++ b/_test/test_tag.py
@@ -3,7 +3,7 @@
import pytest # NOQA
from ruamel import yaml
-from roundtrip import round_trip
+from roundtrip import round_trip, round_trip_load
class XXX(yaml.comments.CommentedMap):
@@ -23,7 +23,6 @@ yaml.add_representer(XXX, XXX.yaml_dump, representer=yaml.RoundTripRepresenter)
class TestIndentFailures:
-
def test_tag(self):
round_trip("""\
!!python/object:__main__.Developer
@@ -104,3 +103,10 @@ class TestRoundTripCustom:
Export:
Name: !Sub "${AWS::StackName}-Vpc" # second tag
""")
+
+
+class TestIssue201:
+ def test_encoded_unicode_tag(self):
+ round_trip_load("""
+ s: !!python/%75nicode 'abc'
+ """)
diff --git a/scanner.py b/scanner.py
index 5e4dccf..0aab137 100644
--- a/scanner.py
+++ b/scanner.py
@@ -1582,7 +1582,7 @@ class Scanner(object):
if PY3:
value = bytes(code_bytes).decode('utf-8')
else:
- value = unicode(''.join(code_bytes), 'utf-8') # type: ignore
+ value = unicode(b''.join(code_bytes), 'utf-8') # type: ignore
except UnicodeDecodeError as exc:
raise ScannerError("while scanning a %s" % name, start_mark,
str(exc), mark)