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

Use pyyaml patch #3520

Merged
merged 14 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,30 @@
--- a/reader.py
+++ b/reader.py
@@ -71,6 +71,7 @@ class Reader(object):
self.index = 0
self.line = 0
self.column = 0
+ self._non_printable = None
if isinstance(stream, unicode):
self.name = "<unicode string>"
self.check_printable(stream)
@@ -136,10 +137,15 @@ 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]')
- else:
- NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
+ @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]')
+ else:
+ self._non_printable = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
+ return self._non_printable
+
def check_printable(self, data):
match = self.NON_PRINTABLE.search(data)
if match:
9 changes: 8 additions & 1 deletion omnibus/config/software/datadog-agent-integrations-py2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@
command "#{pip} install --no-deps .", :env => nix_build_env, :cwd => "#{project_dir}/#{check}"
end
end

# Patch applies to only one file: set it explicitly as a target, no need for -p
if windows?
patch :source => "create-regex-at-runtime.patch", :target => "#{python_2_embedded}/Lib/site-packages/yaml/reader.py"
else
patch :source => "create-regex-at-runtime.patch", :target => "#{install_dir}/embedded/lib/python2.7/site-packages/yaml/reader.py"
end

end

# Run pip check to make sure the agent's python environment is clean, all the dependencies are compatible
Expand All @@ -255,5 +263,4 @@
# Used by the `datadog-agent integration` command to prevent downgrading a check to a version
# older than the one shipped in the agent
copy "#{project_dir}/requirements-agent-release.txt", "#{install_dir}/"

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Each section from every releasenote are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
fixes:
- |
Use a custom patch for a costly regex in PyYAML,
see `<https://github.com/yaml/pyyaml/pull/301>`_.