summaryrefslogtreecommitdiff
path: root/reader.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-09-05 15:18:19 +0200
committerAnthon van der Neut <anthon@mnt.org>2016-09-05 15:18:19 +0200
commit121dfba49da9d9e94f137f09a30eebdcd786e62b (patch)
treebeaafcf5e2027aaa743be727a340c3fbd56125f5 /reader.py
parent10b723f400bc8be58d068f8fdeca2a5332ae837d (diff)
downloadruamel.yaml-121dfba49da9d9e94f137f09a30eebdcd786e62b.tar.gz
rewrite of 32 bit support based on exception0.12.10
Diffstat (limited to 'reader.py')
-rw-r--r--reader.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/reader.py b/reader.py
index fc52d2e..e234b71 100644
--- a/reader.py
+++ b/reader.py
@@ -24,7 +24,7 @@ import codecs
import re
from ruamel.yaml.error import YAMLError, Mark
-from ruamel.yaml.compat import text_type, binary_type, PY3, UNICODE_SIZE
+from ruamel.yaml.compat import text_type, binary_type, PY3
__all__ = ['Reader', 'ReaderError']
@@ -144,7 +144,8 @@ class Reader(object):
self.encoding = 'utf-8'
self.update(1)
- if UNICODE_SIZE == 4:
+ # 4 if 32 bit unicode supported, 2 e.g. on MacOS (issue 56)
+ try:
NON_PRINTABLE = re.compile(
u'[^\x09\x0A\x0D\x20-\x7E\x85'
u'\xA0-\uD7FF'
@@ -152,13 +153,15 @@ class Reader(object):
u'\U00010000-\U0010FFFF'
u']'
)
- else:
+ UNICODE_SIZE = 4
+ except:
NON_PRINTABLE = re.compile(
u'[^\x09\x0A\x0D\x20-\x7E\x85'
u'\xA0-\uD7FF'
u'\uE000-\uFFFD'
u']'
)
+ UNICODE_SIZE = 2
def check_printable(self, data):
match = self.NON_PRINTABLE.search(data)