From 976066a466beeb62fa063157d8439dcf81eceb3a Mon Sep 17 00:00:00 2001 From: Ronuk Raval Date: Tue, 1 Feb 2022 09:09:35 -0500 Subject: [PATCH] Raw strings for RE_BINARY_DIFF `\s` isn't a valid backslash escape for a normal Python escape, which ends up "working" since the `\s` gets preserved verbatim. However, the invalid backslash escape can break other tools that process Python source code, notably `pytest`s assertion rewriting. --- unidiff/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unidiff/constants.py b/unidiff/constants.py index 5d82843..9601cd5 100644 --- a/unidiff/constants.py +++ b/unidiff/constants.py @@ -64,8 +64,8 @@ RE_BINARY_DIFF = re.compile( r'^Binary files? ' - '(?P[^\t]+?)(?:\t(?P[\s0-9:\+-]+))?' - '(?: and (?P[^\t]+?)(?:\t(?P[\s0-9:\+-]+))?)? (differ|has changed)') + r'(?P[^\t]+?)(?:\t(?P[\s0-9:\+-]+))?' + r'(?: and (?P[^\t]+?)(?:\t(?P[\s0-9:\+-]+))?)? (differ|has changed)') DEFAULT_ENCODING = 'UTF-8'