summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Bargull <marcel.bargull@udo.edu>2018-06-16 08:13:29 +0200
committerMarcel Bargull <marcel.bargull@udo.edu>2018-06-16 08:13:29 +0200
commit13cd9b56e285a0ddf4c64e4c5347485bd9ec6546 (patch)
tree57fffc2464800635b134135fe85638bae8e201cb
parent3dbf6566aa45bcf4306be162f4e20a9fbf120d1e (diff)
downloadruamel.yaml-13cd9b56e285a0ddf4c64e4c5347485bd9ec6546.tar.gz
fix _get_non_printable_ascii for PY2
-rw-r--r--reader.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/reader.py b/reader.py
index 0502a94..c454925 100644
--- a/reader.py
+++ b/reader.py
@@ -201,12 +201,13 @@ class Reader(object):
)
UNICODE_SIZE = 4
+ _printable_ascii = ('\x09\x0A\x0D' + ''.join(map(chr, range(0x20, 0x7F)))).encode('ascii')
+
@classmethod
- def _get_non_printable_ascii(
- cls, data, printable=b'\x09\x0A\x0D' + bytes(range(0x20, 0x7E+1))):
+ def _get_non_printable_ascii(cls, data):
# type: (Text, bytes) -> Union[None, Tuple[int, Text]]
ascii_bytes = data.encode('ascii')
- non_printables = ascii_bytes.translate(None, printable)
+ non_printables = ascii_bytes.translate(None, cls._printable_ascii)
if not non_printables:
return None
non_printable = non_printables[:1]