Commit de47fc91 authored by ahochheiden's avatar ahochheiden
Browse files

Bug 1769631 - Remove 'U' from 'mode' parameters for various 'open' calls to...

Bug 1769631 - Remove 'U' from 'mode' parameters for various 'open' calls to ensure Python3.11 compatibility r=firefox-build-system-reviewers,glandium a=RyanVM

The 'U' flag represents "universal newline". It has been deprecated
since Python3.3. Since then "universal newline" is the default when a
file is opened in text mode (not bytes). In Python3.11 using the 'U'
flag throws errors. There should be no harm in removing 'U' from 'open'
everywhere it is used, and doing allows the use of Python3.11.

For more reading see: https://docs.python.org/3.11/whatsnew/3.11.html#changes-in-the-python-api

Differential Revision: https://phabricator.services.mozilla.com/D147721
parent ba6f1567
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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):
+1 −1
Original line number Diff line number Diff line
@@ -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
        )
+1 −1
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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

+1 −1
Original line number Diff line number Diff line
@@ -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
Loading