On 1/5/19 1:07 PM, Jani Nikula wrote:
The re.sub() behaviour for patterns that match both empty and non-emptyInteresting. Feel free to merge ;)
strings has changed in python 3.7. From [1]:
re.sub() now replaces empty matches adjacent to a previous non-empty
match. For example re.sub('x*', '-', 'abxd') returns now '-a-b--d-'
instead of '-a-b-d-' (the first minus between ‘b’ and ‘d’ replaces
‘x’, and the second minus replaces an empty string between ‘x’ and
‘d’).
In our case, this leads to extra newlines being added in
strip_comment(). Work around the issue by first removing the trailing
newlines, and then appending exactly one newline outside of
re.sub(). This is the minimal fix; strip_comment() is in need of an
overhaul anyway.
This fixes test failures on python 3.7+. Tested on python 3.5.3 and
3.7.2rc1.
[1] https://docs.python.org/3/whatsnew/3.7.html
Signed-off-by: Jani Nikula <jani@xxxxxxxxxx>