Skip to content

Commit

Permalink
Update patch for pyyaml 5.4.1 (#7569)
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi authored Mar 3, 2021
1 parent 86e507a commit 66152e5
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--- a/reader.py
+++ b/reader.py
diff --git a/lib/yaml/reader.py b/lib/yaml/reader.py
index 4c42150..481d3d2 100644
--- a/lib/yaml/reader.py
+++ b/lib/yaml/reader.py
@@ -71,6 +71,7 @@ class Reader(object):
self.index = 0
self.line = 0
Expand All @@ -8,21 +10,31 @@
if isinstance(stream, unicode):
self.name = "<unicode string>"
self.check_printable(stream)
@@ -136,10 +137,15 @@ class Reader(object):
@@ -136,15 +137,20 @@ class Reader(object):
self.encoding = 'utf-8'
self.update(1)

- if has_ucs4:
- NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]')
- NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]'
- elif sys.platform.startswith('java'):
- # Jython doesn't support lone surrogates https://bugs.jython.org/issue2048
- NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]'
- else:
- NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)')
- # Need to use eval here due to the above Jython issue
- NON_PRINTABLE = eval(r"u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)'")
- NON_PRINTABLE = re.compile(NON_PRINTABLE)
+ @property
+ def NON_PRINTABLE(self):
+ if self._non_printable is None:
+ if has_ucs4:
+ self._non_printable = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]')
+ NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]'
+ elif sys.platform.startswith('java'):
+ # Jython doesn't support lone surrogates https://bugs.jython.org/issue2048
+ NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]'
+ else:
+ self._non_printable = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)')
+ # Need to use eval here due to the above Jython issue
+ NON_PRINTABLE = eval(r"u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)'")
+ self._non_printable = re.compile(NON_PRINTABLE)
+ return self._non_printable
+
def check_printable(self, data):
Expand Down

0 comments on commit 66152e5

Please sign in to comment.