On Tue, Jan 15, 2019 at 05:03:00PM +0300, Ilya Maximets wrote:
> 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 <[email protected]>
> Signed-off-by: Ilya Maximets <[email protected]>

Thanks a lot!  I applied this to master and backported it as far as it
would go, that is, as far as branch-2.2.

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to