Blame 0001-Python-Build-Use-r-instead-of-rU-file-read-modes.patch

e372916
From 0e790bd2eb846e90495eb81952cf35cc7fc8766a Mon Sep 17 00:00:00 2001
e372916
From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= <fzatlouk@redhat.com>
e372916
Date: Mon, 27 Jun 2022 19:55:16 +0100
e372916
Subject: [PATCH] Python/Build: Use r instead of rU file read modes
e372916
e372916
Fixes Python 3.11 build
e372916
---
e372916
 python/mozbuild/mozbuild/action/process_define_files.py | 2 +-
e372916
 python/mozbuild/mozbuild/backend/base.py                | 2 +-
e372916
 python/mozbuild/mozbuild/preprocessor.py                | 6 +++---
e372916
 python/mozbuild/mozbuild/util.py                        | 4 ++--
e372916
 python/mozbuild/mozpack/files.py                        | 4 ++--
e372916
 5 files changed, 9 insertions(+), 9 deletions(-)
e372916
e372916
diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
e372916
index f1d401a..aca59d0 100644
e372916
--- a/python/mozbuild/mozbuild/action/process_define_files.py
e372916
+++ b/python/mozbuild/mozbuild/action/process_define_files.py
e372916
@@ -36,7 +36,7 @@ def process_define_file(output, input):
e372916
     ) and not config.substs.get("JS_STANDALONE"):
e372916
         config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src"))
e372916
 
e372916
-    with open(path, "rU") as input:
e372916
+    with open(path, "r") as input:
e372916
         r = re.compile(
e372916
             "^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
e372916
         )
e372916
diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py
e372916
index 7bc1986..b64a709 100644
e372916
--- a/python/mozbuild/mozbuild/backend/base.py
e372916
+++ b/python/mozbuild/mozbuild/backend/base.py
e372916
@@ -272,7 +272,7 @@ class BuildBackend(LoggingMixin):
e372916
         return status
e372916
 
e372916
     @contextmanager
e372916
-    def _write_file(self, path=None, fh=None, readmode="rU"):
e372916
+    def _write_file(self, path=None, fh=None, readmode="r"):
e372916
         """Context manager to write a file.
e372916
 
e372916
         This is a glorified wrapper around FileAvoidWrite with integration to
e372916
diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
e372916
index f7820b9..857f1a6 100644
e372916
--- a/python/mozbuild/mozbuild/preprocessor.py
e372916
+++ b/python/mozbuild/mozbuild/preprocessor.py
e372916
@@ -531,7 +531,7 @@ class Preprocessor:
e372916
 
e372916
         if args:
e372916
             for f in args:
e372916
-                with io.open(f, "rU", encoding="utf-8") as input:
e372916
+                with io.open(f, "r", encoding="utf-8") as input:
e372916
                     self.processFile(input=input, output=out)
e372916
             if depfile:
e372916
                 mk = Makefile()
e372916
@@ -860,7 +860,7 @@ class Preprocessor:
e372916
                     args = self.applyFilters(args)
e372916
                 if not os.path.isabs(args):
e372916
                     args = os.path.join(self.curdir, args)
e372916
-                args = io.open(args, "rU", encoding="utf-8")
e372916
+                args = io.open(args, "r", encoding="utf-8")
e372916
             except Preprocessor.Error:
e372916
                 raise
e372916
             except Exception:
e372916
@@ -914,7 +914,7 @@ class Preprocessor:
e372916
 def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"):
e372916
     pp = Preprocessor(defines=defines, marker=marker)
e372916
     for f in includes:
e372916
-        with io.open(f, "rU", encoding="utf-8") as input:
e372916
+        with io.open(f, "r", encoding="utf-8") as input:
e372916
             pp.processFile(input=input, output=output)
e372916
     return pp.includes
e372916
 
e372916
diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
e372916
index 071daec..b59aabb 100644
e372916
--- a/python/mozbuild/mozbuild/util.py
e372916
+++ b/python/mozbuild/mozbuild/util.py
e372916
@@ -225,7 +225,7 @@ class FileAvoidWrite(BytesIO):
e372916
     still occur, as well as diff capture if requested.
e372916
     """
e372916
 
e372916
-    def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"):
e372916
+    def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"):
e372916
         BytesIO.__init__(self)
e372916
         self.name = filename
e372916
         assert type(capture_diff) == bool
e372916
@@ -1447,7 +1447,7 @@ def patch_main():
e372916
 
e372916
         def my_get_command_line():
e372916
             with open(
e372916
-                os.path.join(os.path.dirname(__file__), "fork_interpose.py"), "rU"
e372916
+                os.path.join(os.path.dirname(__file__), "fork_interpose.py"), "r"
e372916
             ) as fork_file:
e372916
                 fork_code = fork_file.read()
e372916
             # Add our relevant globals.
e372916
diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py
e372916
index 8150e72..001c497 100644
e372916
--- a/python/mozbuild/mozpack/files.py
e372916
+++ b/python/mozbuild/mozpack/files.py
e372916
@@ -574,7 +574,7 @@ class PreprocessedFile(BaseFile):
e372916
         pp = Preprocessor(defines=self.defines, marker=self.marker)
e372916
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
e372916
 
e372916
-        with _open(self.path, "rU") as input:
e372916
+        with _open(self.path, "r") as input:
e372916
             with _open(os.devnull, "w") as output:
e372916
                 pp.processFile(input=input, output=output)
e372916
 
e372916
@@ -631,7 +631,7 @@ class PreprocessedFile(BaseFile):
e372916
         pp = Preprocessor(defines=self.defines, marker=self.marker)
e372916
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
e372916
 
e372916
-        with _open(self.path, "rU") as input:
e372916
+        with _open(self.path, "r") as input:
e372916
             pp.processFile(input=input, output=dest, depfile=deps_out)
e372916
 
e372916
         dest.close()
e372916
-- 
e372916
2.36.1
e372916