From d07a1a5ec56d5025561f2c293ce1d928f0781078 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 26 Feb 2024 08:26:38 +0000 Subject: [PATCH] Bug 1879120 - Remove all python deprecation warning: invalid escape sequence r=ahochheiden,webdriver-reviewers,perftest-reviewers,afinder UPGRADE_NSPR_RELEASE Differential Revision: https://phabricator.services.mozilla.com/D201012 --- build/pgo/genpgocert.py | 8 ++++---- .../third_party_build/filter_git_changes.py | 2 +- .../webrtc/third_party_build/save_patch_stack.py | 2 +- gfx/angle/update-angle.py | 2 +- gfx/thebes/gencjkcisvs.py | 2 +- js/src/builtin/intl/make_intl_data.py | 8 ++++---- js/src/frontend/align_stack_comment.py | 2 +- js/src/gdb/mozilla/prettyprinters.py | 2 +- js/src/gdb/run-tests.py | 4 ++-- js/src/gdb/tests/test-ExecutableAllocator.py | 4 ++-- js/src/tests/lib/tasks_adb_remote.py | 2 +- .../String/make-normalize-generateddata-input.py | 2 +- js/src/tests/test262-export.py | 2 +- js/src/util/make_unicode.py | 2 +- layout/tools/reftest/runreftest.py | 2 +- media/libaom/cmakeparser.py | 4 ++-- .../automation/release/nspr-release-helper.py | 16 ++++++++-------- .../bug_1845150_search_engine_notification.py | 2 +- .../mozbuild/action/langpack_manifest.py | 2 +- python/mozbuild/mozbuild/backend/cpp_eclipse.py | 6 +++--- .../mozbuild/mozbuild/codecoverage/chrome_map.py | 2 +- .../mozbuild/configure/check_debug_ranges.py | 2 +- python/mozbuild/mozbuild/dotproperties.py | 2 +- python/mozbuild/mozbuild/repackaging/msix.py | 10 +++++----- .../test/configure/test_toolchain_helpers.py | 8 ++++---- .../mozbuild/mozbuild/vendor/rewrite_mozbuild.py | 2 +- .../mozbuild/mozbuild/vendor/vendor_manifest.py | 2 +- python/mozrelease/mozrelease/partner_repack.py | 2 +- servo/components/style/gecko/regen_atoms.py | 2 +- taskcluster/scripts/misc/are-we-esmified-yet.py | 4 ++-- testing/firefox-ui/harness/setup.py | 2 +- testing/jsshell/benchmark.py | 12 ++++++------ testing/marionette/client/setup.py | 2 +- .../harness/marionette_harness/runner/base.py | 2 +- .../tests/unit/test_pagesource.py | 2 +- testing/marionette/harness/setup.py | 2 +- testing/mochitest/leaks.py | 14 +++++++------- .../mozgeckoprofiler/symbolicationRequest.py | 2 +- .../tests/test_view_gecko_profiler.py | 2 +- testing/mozbase/mozhttpd/tests/filelisting.py | 2 +- testing/mozbase/mozleak/mozleak/lsan.py | 10 +++++----- .../mozbase/moznetwork/tests/test_moznetwork.py | 4 ++-- .../mozrunner/devices/android_device.py | 2 +- .../marionette/windows_taskcluster_config.py | 8 ++++---- .../prod_config_windows_taskcluster.py | 8 ++++---- .../mozharness/examples/action_config_script.py | 4 ++-- .../mozharness/external_tools/robustcheckout.py | 2 +- .../mozharness/mozilla/firefox/autoconfig.py | 2 +- testing/mozharness/scripts/openh264_build.py | 2 +- testing/talos/talos/allowlist.py | 2 +- testing/talos/talos/results.py | 2 +- testing/talos/talos/xtalos/etlparser.py | 6 +++--- testing/talos/talos/xtalos/xperf_analyzer.py | 4 ++-- testing/tps/tps/cli.py | 2 +- testing/web-platform/metasummary.py | 4 ++-- .../mozilla/tests/webdriver/support/fixtures.py | 2 +- .../tests/annotation-model/tools/make_tests.py | 6 +++--- .../syntax/speculative-parsing/tools/generate.py | 2 +- testing/web-platform/unittestrunner.py | 2 +- testing/web-platform/update/tree.py | 6 +++--- testing/web-platform/update/upstream.py | 2 +- testing/webcompat/fixtures.py | 2 +- testing/xpcshell/selftest.py | 6 +++--- toolkit/crashreporter/tools/symbolstore.py | 2 +- tools/lint/cpp/mingw-capitalization.py | 2 +- tools/lint/perfdocs/framework_gatherers.py | 4 ++-- tools/lint/perfdocs/verifier.py | 4 ++-- tools/lint/yamllint_/__init__.py | 4 +++- tools/rb/fix_stacks.py | 2 +- 69 files changed, 132 insertions(+), 130 deletions(-) diff --git a/build/pgo/genpgocert.py b/build/pgo/genpgocert.py index 8edaa47ba980..e844946466f1 100644 --- a/build/pgo/genpgocert.py +++ b/build/pgo/genpgocert.py @@ -20,9 +20,9 @@ from mozfile import NamedTemporaryFile, TemporaryDirectory from mozprofile.permissions import ServerLocations dbFiles = [ - re.compile("^cert[0-9]+\.db$"), - re.compile("^key[0-9]+\.db$"), - re.compile("^secmod\.db$"), + re.compile(r"^cert[0-9]+\.db$"), + re.compile(r"^key[0-9]+\.db$"), + re.compile(r"^secmod\.db$"), ] @@ -77,7 +77,7 @@ def writeCertspecForServerLocations(fd): i for i in iter(locations) if i.scheme == "https" and "nocert" not in i.options ]: customCertOption = False - customCertRE = re.compile("^cert=(?:\w+)") + customCertRE = re.compile(r"^cert=(?:\w+)") for _ in [i for i in loc.options if customCertRE.match(i)]: customCertOption = True break diff --git a/dom/media/webrtc/third_party_build/filter_git_changes.py b/dom/media/webrtc/third_party_build/filter_git_changes.py index ee6cdbcbd996..86358b0b01e3 100644 --- a/dom/media/webrtc/third_party_build/filter_git_changes.py +++ b/dom/media/webrtc/third_party_build/filter_git_changes.py @@ -48,7 +48,7 @@ def filter_git_changes(github_path, commit_sha, diff_filter): # out the excluded directory paths (note the lack of trailing '$' # in the regex). regex_excludes = "|".join( - ["^(M|A|D|R\d\d\d)\t{}".format(i) for i in exclude_dir_list] + ["^(M|A|D|R\\d\\d\\d)\t{}".format(i) for i in exclude_dir_list] ) files_not_excluded = [ path for path in changed_files if not re.findall(regex_excludes, path) diff --git a/dom/media/webrtc/third_party_build/save_patch_stack.py b/dom/media/webrtc/third_party_build/save_patch_stack.py index 9b080ac0ff29..907b90f59307 100644 --- a/dom/media/webrtc/third_party_build/save_patch_stack.py +++ b/dom/media/webrtc/third_party_build/save_patch_stack.py @@ -52,7 +52,7 @@ def save_patch_stack( # remove the commit summary from the file name patches_to_rename = os.listdir(patch_directory) for file in patches_to_rename: - shortened_name = re.sub("^(\d\d\d\d)-.*\.patch", "\\1.patch", file) + shortened_name = re.sub(r"^(\d\d\d\d)-.*\.patch", "\\1.patch", file) os.rename( os.path.join(patch_directory, file), os.path.join(patch_directory, shortened_name), diff --git a/gfx/angle/update-angle.py b/gfx/angle/update-angle.py index 348a1cf745f8..7b37d7b8732d 100755 --- a/gfx/angle/update-angle.py +++ b/gfx/angle/update-angle.py @@ -5,7 +5,7 @@ assert __name__ == "__main__" -""" +r""" To update ANGLE in Gecko, use Windows with git-bash, and setup depot_tools, python2, and python3. Because depot_tools expects `python` to be `python2` (shame!), python2 must come before python3 in your path. diff --git a/gfx/thebes/gencjkcisvs.py b/gfx/thebes/gencjkcisvs.py index 6a28e7d49208..000b3f571120 100644 --- a/gfx/thebes/gencjkcisvs.py +++ b/gfx/thebes/gencjkcisvs.py @@ -9,7 +9,7 @@ import sys f = open(sys.argv[1] if len(sys.argv) > 1 else "StandardizedVariants.txt") line = f.readline() -m = re.compile("^# (StandardizedVariants(-\d+(\.\d+)*)?\.txt)").search(line) +m = re.compile(r"^# (StandardizedVariants(-\d+(\.\d+)*)?\.txt)").search(line) fileversion = m.group(1) vsdict = {} r = re.compile( diff --git a/js/src/builtin/intl/make_intl_data.py b/js/src/builtin/intl/make_intl_data.py index 7042c0a005d0..a8357445c4fc 100755 --- a/js/src/builtin/intl/make_intl_data.py +++ b/js/src/builtin/intl/make_intl_data.py @@ -2213,7 +2213,7 @@ def listIANAFiles(tzdataDir): def readIANAFiles(tzdataDir, files): """Read all IANA time zone files from the given iterable.""" - nameSyntax = "[\w/+\-]+" + nameSyntax = r"[\w/+\-]+" pZone = re.compile(r"Zone\s+(?P%s)\s+.*" % nameSyntax) pLink = re.compile( r"Link\s+(?P%s)\s+(?P%s)(?:\s+#.*)?" % (nameSyntax, nameSyntax) @@ -2310,7 +2310,7 @@ def readICUResourceFile(filename): maybeMultiComments = r"(?:/\*[^*]*\*/)*" maybeSingleComment = r"(?://.*)?" lineStart = "^%s" % maybeMultiComments - lineEnd = "%s\s*%s$" % (maybeMultiComments, maybeSingleComment) + lineEnd = r"%s\s*%s$" % (maybeMultiComments, maybeSingleComment) return re.compile(r"\s*".join(chain([lineStart], args, [lineEnd]))) tableName = r'(?P"?)(?P.+?)(?P=quote)' @@ -2554,7 +2554,7 @@ def icuTzDataVersion(icuTzDir): zoneinfo = os.path.join(icuTzDir, "zoneinfo64.txt") if not os.path.isfile(zoneinfo): raise RuntimeError("file not found: %s" % zoneinfo) - version = searchInFile("^//\s+tz version:\s+([0-9]{4}[a-z])$", zoneinfo) + version = searchInFile(r"^//\s+tz version:\s+([0-9]{4}[a-z])$", zoneinfo) if version is None: raise RuntimeError( "%s does not contain a valid tzdata version string" % zoneinfo @@ -3711,7 +3711,7 @@ const allUnits = {}; """.format( all_units_array ) - + """ + + r""" // Test only sanctioned unit identifiers are allowed. for (const typeAndUnit of allUnits) { diff --git a/js/src/frontend/align_stack_comment.py b/js/src/frontend/align_stack_comment.py index 28d5d8cf7fe1..6e279a90c632 100755 --- a/js/src/frontend/align_stack_comment.py +++ b/js/src/frontend/align_stack_comment.py @@ -22,7 +22,7 @@ ALIGNMENT_COLUMN = 20 # The maximum column for comment MAX_CHARS_PER_LINE = 80 -stack_comment_pat = re.compile("^( *//) *(\[stack\].*)$") +stack_comment_pat = re.compile(r"^( *//) *(\[stack\].*)$") def align_stack_comment(path): diff --git a/js/src/gdb/mozilla/prettyprinters.py b/js/src/gdb/mozilla/prettyprinters.py index b533d1f1f52f..12847cae7ca2 100644 --- a/js/src/gdb/mozilla/prettyprinters.py +++ b/js/src/gdb/mozilla/prettyprinters.py @@ -271,7 +271,7 @@ def implemented_types(t): yield t2 -template_regexp = re.compile("([\w_:]+)<") +template_regexp = re.compile(r"([\w_:]+)<") def is_struct_or_union(t): diff --git a/js/src/gdb/run-tests.py b/js/src/gdb/run-tests.py index cb9501e90485..063a550b17c1 100644 --- a/js/src/gdb/run-tests.py +++ b/js/src/gdb/run-tests.py @@ -40,9 +40,9 @@ def _relpath(path, start=None): os.path.relpath = _relpath # Characters that need to be escaped when used in shell words. -shell_need_escapes = re.compile("[^\w\d%+,-./:=@'\"]", re.DOTALL) +shell_need_escapes = re.compile("[^\\w\\d%+,-./:=@'\"]", re.DOTALL) # Characters that need to be escaped within double-quoted strings. -shell_dquote_escapes = re.compile('[^\w\d%+,-./:=@"]', re.DOTALL) +shell_dquote_escapes = re.compile('[^\\w\\d%+,-./:=@"]', re.DOTALL) def make_shell_cmd(l): diff --git a/js/src/gdb/tests/test-ExecutableAllocator.py b/js/src/gdb/tests/test-ExecutableAllocator.py index bec2dda62307..6a3ae4aae1ec 100644 --- a/js/src/gdb/tests/test-ExecutableAllocator.py +++ b/js/src/gdb/tests/test-ExecutableAllocator.py @@ -13,10 +13,10 @@ run_fragment("ExecutableAllocator.onepool") reExecPool = "ExecutablePool [a-f0-9]{8,}-[a-f0-9]{8,}" assert_regexp_pretty("pool", reExecPool) -assert_regexp_pretty("execAlloc", "ExecutableAllocator\(\[" + reExecPool + "\]\)") +assert_regexp_pretty("execAlloc", r"ExecutableAllocator\(\[" + reExecPool + r"\]\)") run_fragment("ExecutableAllocator.twopools") assert_regexp_pretty( - "execAlloc", "ExecutableAllocator\(\[" + reExecPool + ", " + reExecPool + "\]\)" + "execAlloc", r"ExecutableAllocator\(\[" + reExecPool + ", " + reExecPool + r"\]\)" ) diff --git a/js/src/tests/lib/tasks_adb_remote.py b/js/src/tests/lib/tasks_adb_remote.py index 2d2739a281d8..1ddc6baa0859 100644 --- a/js/src/tests/lib/tasks_adb_remote.py +++ b/js/src/tests/lib/tasks_adb_remote.py @@ -160,7 +160,7 @@ do_test() # # The timeout command send a SIGTERM signal, which should return 143 # (=128+15). However, due to a bug in tinybox, it returns 142. - if test \( $rc -eq 143 -o $rc -eq 142 \) -a $attempt -lt {retry}; then + if test \\( $rc -eq 143 -o $rc -eq 142 \\) -a $attempt -lt {retry}; then echo '\\n{tag}RETRY='$rc,$time attempt=$((attempt + 1)) do_test $idx $attempt "$@" diff --git a/js/src/tests/non262/String/make-normalize-generateddata-input.py b/js/src/tests/non262/String/make-normalize-generateddata-input.py index 5c3d2d3e442c..086275e67d35 100644 --- a/js/src/tests/non262/String/make-normalize-generateddata-input.py +++ b/js/src/tests/non262/String/make-normalize-generateddata-input.py @@ -18,7 +18,7 @@ def to_code_list(codes): def convert(dir): - ver_pat = re.compile("NormalizationTest-([0-9\.]+)\.txt") + ver_pat = re.compile(r"NormalizationTest-([0-9\.]+)\.txt") part_pat = re.compile("^@(Part([0-9]+) .+)$") test_pat = re.compile( "^([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);$" diff --git a/js/src/tests/test262-export.py b/js/src/tests/test262-export.py index 477db883ea96..dc3077697393 100755 --- a/js/src/tests/test262-export.py +++ b/js/src/tests/test262-export.py @@ -237,7 +237,7 @@ def mergeMeta(reftest, frontmatter, includes): if info: # Open some space in an existing info text if "info" in frontmatter: - frontmatter["info"] += "\n\n \%s" % info + frontmatter["info"] += "\n\n \\%s" % info else: frontmatter["info"] = info diff --git a/js/src/util/make_unicode.py b/js/src/util/make_unicode.py index 6ddecd6cbb44..21ad718f3ec2 100755 --- a/js/src/util/make_unicode.py +++ b/js/src/util/make_unicode.py @@ -1111,7 +1111,7 @@ def make_regexp_space_test(version, test_space_table, codepoint_table): test_space.write(",\n".join(map(hex_and_name, test_space_table))) test_space.write("\n);\n") test_space.write( - """ + r""" assertEq(/^\s+$/.exec(onlySpace) !== null, true); assertEq(/^[\s]+$/.exec(onlySpace) !== null, true); assertEq(/^[^\s]+$/.exec(onlySpace) === null, true); diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index b42e8e02389b..cf314c99b540 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -252,7 +252,7 @@ class ReftestResolver(object): rv = [ ( os.path.join(dirname, default_manifest), - r".*%s(?:[#?].*)?$" % pathname.replace("?", "\?"), + r".*%s(?:[#?].*)?$" % pathname.replace("?", r"\?"), ) ] diff --git a/media/libaom/cmakeparser.py b/media/libaom/cmakeparser.py index b93a313bce9b..261f05fb17ea 100644 --- a/media/libaom/cmakeparser.py +++ b/media/libaom/cmakeparser.py @@ -83,7 +83,7 @@ def substs(variables, values): # Safe substitute leaves unrecognized variables in place. # We replace them with the empty string. - new_values.append(re.sub('\$\{\w+\}', '', new_value)) + new_values.append(re.sub(r'\$\{\w+\}', '', new_value)) return new_values @@ -240,7 +240,7 @@ def evaluate_boolean(variables, arguments): # If statements can have old-style variables which are not demarcated # like ${VARIABLE}. Attempt to look up the variable both ways. try: - if re.search('\$\{\w+\}', argument): + if re.search(r'\$\{\w+\}', argument): try: t = Template(argument) value = t.substitute(variables) diff --git a/nsprpub/automation/release/nspr-release-helper.py b/nsprpub/automation/release/nspr-release-helper.py index f62b80404a10..582854e2a0eb 100644 --- a/nsprpub/automation/release/nspr-release-helper.py +++ b/nsprpub/automation/release/nspr-release-helper.py @@ -46,13 +46,13 @@ def toggle_beta_status(is_beta): check_files_exist() if (is_beta): print("adding Beta status to version numbers") - sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', prinit_h) - sed_inplace('s/^\(#define *PR_BETA *\)PR_FALSE *$/\\1PR_TRUE/', prinit_h) + sed_inplace('s/^\\(#define *PR_VERSION *\"[0-9.]\\+\\)\" *$/\\1 Beta\"/', prinit_h) + sed_inplace('s/^\\(#define *PR_BETA *\\)PR_FALSE *$/\\1PR_TRUE/', prinit_h) else: print("removing Beta status from version numbers") - sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', prinit_h) - sed_inplace('s/^\(#define *PR_BETA *\)PR_TRUE *$/\\1PR_FALSE/', prinit_h) + sed_inplace('s/^\\(#define *PR_VERSION *\"[0-9.]\\+\\) *Beta\" *$/\\1\"/', prinit_h) + sed_inplace('s/^\\(#define *PR_BETA *\\)PR_TRUE *$/\\1PR_FALSE/', prinit_h) print("please run 'hg stat' and 'hg diff' to verify the files have been verified correctly") def print_beta_versions(): @@ -81,22 +81,22 @@ def ensure_arguments_after_action(how_many, usage): exit_with_failure("incorrect number of arguments, expected parameters are:\n" + usage) def set_major_versions(major): - sed_inplace('s/^\(#define *PR_VMAJOR *\).*$/\\1' + major + '/', prinit_h) + sed_inplace('s/^\\(#define *PR_VMAJOR *\\).*$/\\1' + major + '/', prinit_h) sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf) sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf_in) def set_minor_versions(minor): - sed_inplace('s/^\(#define *PR_VMINOR *\).*$/\\1' + minor + '/', prinit_h) + sed_inplace('s/^\\(#define *PR_VMINOR *\\).*$/\\1' + minor + '/', prinit_h) sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf) sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf_in) def set_patch_versions(patch): - sed_inplace('s/^\(#define *PR_VPATCH *\).*$/\\1' + patch + '/', prinit_h) + sed_inplace('s/^\\(#define *PR_VPATCH *\\).*$/\\1' + patch + '/', prinit_h) sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf) sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf_in) def set_full_lib_versions(version): - sed_inplace('s/^\(#define *PR_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', prinit_h) + sed_inplace('s/^\\(#define *PR_VERSION *\"\\)\\([0-9.]\\+\\)\\(.*\\)$/\\1' + version + '\\3/', prinit_h) def set_all_lib_versions(version, major, minor, patch): set_full_lib_versions(version) diff --git a/python/l10n/fluent_migrations/bug_1845150_search_engine_notification.py b/python/l10n/fluent_migrations/bug_1845150_search_engine_notification.py index 125baa4c1fbe..a519833d9c0c 100644 --- a/python/l10n/fluent_migrations/bug_1845150_search_engine_notification.py +++ b/python/l10n/fluent_migrations/bug_1845150_search_engine_notification.py @@ -10,7 +10,7 @@ class STRIP_LABEL(TransformPattern): # Used to remove `