Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[omnibus] Update patch for pyyaml 5.4.1 #7569

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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