Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
openvswitch-dpdk.10750
0008-python-Escape-backslashes-while-formatting...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0008-python-Escape-backslashes-while-formatting-logs.patch of Package openvswitch-dpdk.10750
From 79b7778006cb26f972339f0ccd34ddd0ca1edff8 Mon Sep 17 00:00:00 2001 From: Ilya Maximets <i.maximets@samsung.com> Date: Tue, 15 Jan 2019 17:03:00 +0300 Subject: [PATCH 08/14] python: Escape backslashes while formatting logs. Since python version 3.7 (and some 3.6+ versions) regexp engine changed to treat the wrong escape sequences as errors. Previously, if the replace string had something like '\u0000', '\u' was qualified as a bad escape sequence and treated just as a sequence of characters '\' and 'u'. But know this triggers an error: Traceback (most recent call last): File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template this = chr(ESCAPES[this][1]) KeyError: '\\u' From the documentation [1]: Unknown escapes consisting of '\' and an ASCII letter in replacement templates for re.sub() were deprecated in Python 3.5, and will now cause an error. [1] https://docs.python.org/3/whatsnew/3.7.html#api-and-feature-removals We need to escape the backslash by another one to keep regexp engine from errors. In case of '\\u000', '\\' is a valid escape sequence and the 'u' is a simple character. To be 100% safe we need to use 're.escape(replace)', but it escapes too many characters making the logs hard to read. This change fixes Python 3 tests on systems with python 3.7. Should be backward compatible. Reported-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org> --- python/ovs/vlog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py index d5741a65f..60cece29e 100644 --- a/python/ovs/vlog.py +++ b/python/ovs/vlog.py @@ -136,7 +136,7 @@ class Vlog: min_width = int(matches.group(2)) if len(replace) < min_width: replace = replace.center(min_width) - return re.sub(match, replace, tmp) + return re.sub(match, replace.replace('\\', r'\\'), tmp) def _format_time(self, tmp): date_regex = re.compile('(%(0?[1-9]?[dD])(\{(.*)\})?)') -- 2.21.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor