diff options
Diffstat (limited to 'reader.py')
-rw-r--r-- | reader.py | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -25,6 +25,7 @@ import re from ruamel.yaml.error import YAMLError, FileMark, StringMark, YAMLStreamError from ruamel.yaml.compat import text_type, binary_type, PY3 +from ruamel.yaml.util import RegExp if False: # MYPY from typing import Any, Dict, Optional, List, Union, Text # NOQA @@ -181,22 +182,24 @@ class Reader(object): # 4 if 32 bit unicode supported, 2 e.g. on MacOS (issue 56) try: - NON_PRINTABLE = re.compile( + re.compile(u'[^\U00010000]') + except: + NON_PRINTABLE = RegExp( u'[^\x09\x0A\x0D\x20-\x7E\x85' u'\xA0-\uD7FF' u'\uE000-\uFFFD' - u'\U00010000-\U0010FFFF' u']' ) - UNICODE_SIZE = 4 - except: - NON_PRINTABLE = re.compile( + UNICODE_SIZE = 2 + else: + NON_PRINTABLE = RegExp( u'[^\x09\x0A\x0D\x20-\x7E\x85' u'\xA0-\uD7FF' u'\uE000-\uFFFD' + u'\U00010000-\U0010FFFF' u']' ) - UNICODE_SIZE = 2 + UNICODE_SIZE = 4 def check_printable(self, data): # type: (Any) -> None |