From f0749951069e9344a85657c79a8e3155a599363d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 9 Jul 2020 15:54:34 -0700 Subject: [PATCH] test: partially undo changes to `PathSanitizingFileCheck` The regular expression engine escaped the strings differently across python 2 and 3. Using a raw string makes this simpler to understand and obsoletes the comment. This change also now properly allows the replacement to occur in the same way on 2 and 3. --- utils/PathSanitizingFileCheck | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/PathSanitizingFileCheck b/utils/PathSanitizingFileCheck index 3496895ec0d07..030fe04fdb2b0 100755 --- a/utils/PathSanitizingFileCheck +++ b/utils/PathSanitizingFileCheck @@ -80,10 +80,9 @@ constants.""") # Since we want to use pattern as a regex in some platforms, we need # to escape it first, and then replace the escaped slash # literal (r'\\/') for our platform-dependent slash regex. - stdin = re.sub(re.sub('\\\\/' if sys.version_info[0] < 3 else r'[/\\]', + stdin = re.sub(re.sub(r'\\/' if sys.version_info[0] < 3 else r'/', slashes_re, re.escape(pattern)), - replacement, - stdin) + replacement, stdin) if args.dry_run: print(stdin)