Python 3.11: Don't use mode "rU" any more
authorCarsten Schoenert <c.schoenert@t-online.de>
Mon, 16 Jan 2023 18:34:11 +0000 (19:34 +0100)
committerCarsten Schoenert <c.schoenert@t-online.de>
Tue, 24 Jan 2023 15:32:06 +0000 (15:32 +0000)
Python 3.11 isn't using this mode that way any more, also adjust some
regexp rules.

Gbp-Pq: Topic debian-hacks
Gbp-Pq: Name Python-3.11-Don-t-use-mode-rU-any-more.patch

dom/base/usecounters.py
python/mozbuild/mozbuild/action/process_define_files.py
python/mozbuild/mozbuild/backend/base.py
python/mozbuild/mozbuild/preprocessor.py
python/mozbuild/mozbuild/util.py
python/mozbuild/mozpack/files.py
xpcom/idl-parser/xpidl/xpidl.py

index 780e3b32b21318caad9ceb3050155c22bab0fabf..7e2c7148ece554f53f9761e0c999bb742e21e3b5 100644 (file)
@@ -8,7 +8,7 @@ import re
 
 def read_conf(conf_filename):
     # Can't read/write from a single StringIO, so make a new one for reading.
-    stream = open(conf_filename, "rU")
+    stream = open(conf_filename, "r")
 
     def parse_counters(stream):
         for line_num, line in enumerate(stream):
index f1d401ac2600667fc7b0550fe56bd2d7dd0a536f..aca59d0f051775598ecc94d253be7d4b2bd70693 100644 (file)
@@ -36,7 +36,7 @@ def process_define_file(output, input):
     ) and not config.substs.get("JS_STANDALONE"):
         config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src"))
 
-    with open(path, "rU") as input:
+    with open(path, "r") as input:
         r = re.compile(
             "^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
         )
index 7bc1986d863b5377d8326efa3edd36821dd4352d..b64a70946863d22c61b2013f04df4256e726532b 100644 (file)
@@ -272,7 +272,7 @@ class BuildBackend(LoggingMixin):
         return status
 
     @contextmanager
-    def _write_file(self, path=None, fh=None, readmode="rU"):
+    def _write_file(self, path=None, fh=None, readmode="r"):
         """Context manager to write a file.
 
         This is a glorified wrapper around FileAvoidWrite with integration to
index f7820b9c91473f81b5cc133411c4920de1099793..857f1a6c9bfd17b9678fb9c9899424458e75d158 100644 (file)
@@ -531,7 +531,7 @@ class Preprocessor:
 
         if args:
             for f in args:
-                with io.open(f, "rU", encoding="utf-8") as input:
+                with io.open(f, "r", encoding="utf-8") as input:
                     self.processFile(input=input, output=out)
             if depfile:
                 mk = Makefile()
@@ -860,7 +860,7 @@ class Preprocessor:
                     args = self.applyFilters(args)
                 if not os.path.isabs(args):
                     args = os.path.join(self.curdir, args)
-                args = io.open(args, "rU", encoding="utf-8")
+                args = io.open(args, "r", encoding="utf-8")
             except Preprocessor.Error:
                 raise
             except Exception:
@@ -914,7 +914,7 @@ class Preprocessor:
 def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"):
     pp = Preprocessor(defines=defines, marker=marker)
     for f in includes:
-        with io.open(f, "rU", encoding="utf-8") as input:
+        with io.open(f, "r", encoding="utf-8") as input:
             pp.processFile(input=input, output=output)
     return pp.includes
 
index b09f1646988f0ea1c7051c1952817b655b765f80..4f1e0cdc5f5688822f1351d1a755725602f1b26a 100644 (file)
@@ -236,7 +236,7 @@ class FileAvoidWrite(BytesIO):
     still occur, as well as diff capture if requested.
     """
 
-    def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"):
+    def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"):
         BytesIO.__init__(self)
         self.name = filename
         assert type(capture_diff) == bool
index 1d8a1ed2d8a7e983ac01d8d491015f6cf2d3f780..a295a67b5a34f53823808042e70cefffdae87f0e 100644 (file)
@@ -554,7 +554,7 @@ class PreprocessedFile(BaseFile):
         pp = Preprocessor(defines=self.defines, marker=self.marker)
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
 
-        with _open(self.path, "rU") as input:
+        with _open(self.path, "r") as input:
             with _open(os.devnull, "w") as output:
                 pp.processFile(input=input, output=output)
 
@@ -611,7 +611,7 @@ class PreprocessedFile(BaseFile):
         pp = Preprocessor(defines=self.defines, marker=self.marker)
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
 
-        with _open(self.path, "rU") as input:
+        with _open(self.path, "r") as input:
             pp.processFile(input=input, output=dest, depfile=deps_out)
 
         dest.close()
index 758a44ce56044ef0a4cba49dde2a1a85ddbc78ef..f14e4ca68ef1004047225b9937605e8454945b9c 100755 (executable)
@@ -1572,13 +1572,13 @@ class IDLParser(object):
     t_ignore = " \t"
 
     def t_multilinecomment(self, t):
-        r"/\*(?s).*?\*/"
+        r"/\*(?s:.*?)\*/"
         t.lexer.lineno += t.value.count("\n")
         if t.value.startswith("/**"):
             self._doccomments.append(t.value)
 
     def t_singlelinecomment(self, t):
-        r"(?m)//.*?$"
+        r"(?m://.*?$)"
 
     def t_IID(self, t):
         return t
@@ -1591,7 +1591,7 @@ class IDLParser(object):
         return t
 
     def t_LCDATA(self, t):
-        r"(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?"
+        r"(?s:%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?)"
         t.type = "CDATA"
         t.value = t.lexer.lexmatch.group("cdata")
         t.lexer.lineno += t.value.count("\n")