Bug 1719144 - Fix various imports for Python 3.10. r=firefox-build-system-reviewers,mhentges
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 06 Jul 2021 15:26:29 +0000 (2021-07-06)
changeset 584866 2418633d529c6df00a83e973295eed0e891990a6
parent 584865 0b5bfe85b344b34894f72176099da78c3849b5cc
child 584867 c3b650ea51c9719d130a27c889e8438adf098d6d
push id145845
push userealvarez@mozilla.com
push dateTue, 06 Jul 2021 15:40:02 +0000 (2021-07-06)
treeherderautoland@c3b650ea51c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, mhentges
bugs1719144
milestone91.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1719144 - Fix various imports for Python 3.10. r=firefox-build-system-reviewers,mhentges These are enough for me to run bootstrap+configure+build. Some touch third-party code (gyp), but per discussion in the earlier versions of this revision that seems fine. Differential Revision: https://phabricator.services.mozilla.com/D119080
python/mach/mach/config.py
python/mach/mach/decorators.py
python/mach/mach/main.py
python/mozbuild/mozbuild/backend/configenvironment.py
python/mozbuild/mozbuild/makeutil.py
python/mozbuild/mozbuild/util.py
taskcluster/taskgraph/util/schema.py
testing/mozbase/manifestparser/manifestparser/filters.py
third_party/python/gyp/pylib/gyp/common.py
--- a/python/mach/mach/config.py
+++ b/python/mach/mach/config.py
@@ -12,16 +12,17 @@ them. This metadata includes type, defau
 The main interface to config data is the ConfigSettings class. 1 or more
 ConfigProvider classes are associated with ConfigSettings and define what
 settings are available.
 """
 
 from __future__ import absolute_import, unicode_literals
 
 import collections
+import collections.abc
 import os
 import sys
 import six
 from functools import wraps
 from six.moves.configparser import RawConfigParser, NoSectionError
 from six import string_types
 
 
@@ -141,17 +142,17 @@ def reraise_attribute_error(func):
             return func(*args, **kwargs)
         except KeyError:
             exc_class, exc, tb = sys.exc_info()
             six.reraise(AttributeError().__class__, exc, tb)
 
     return _
 
 
-class ConfigSettings(collections.Mapping):
+class ConfigSettings(collections.abc.Mapping):
     """Interface for configuration settings.
 
     This is the main interface to the configuration.
 
     A configuration is a collection of sections. Each section contains
     key-value pairs.
 
     When an instance is created, the caller first registers ConfigProvider
@@ -187,17 +188,17 @@ class ConfigSettings(collections.Mapping
 
     If there is a default, it will be returned.
 
     When settings are mutated, they are validated against the registered
     providers. Setting unknown settings or setting values to illegal values
     will result in exceptions being raised.
     """
 
-    class ConfigSection(collections.MutableMapping, object):
+    class ConfigSection(collections.abc.MutableMapping, object):
         """Represents an individual config section."""
 
         def __init__(self, config, name, settings):
             object.__setattr__(self, "_config", config)
             object.__setattr__(self, "_name", name)
             object.__setattr__(self, "_settings", settings)
 
             wildcard = any(s == "*" for s in self._settings)
@@ -312,23 +313,17 @@ class ConfigSettings(collections.Mapping
         for fp in fps:
             self._config.readfp(fp)
 
     def write(self, fh):
         """Write the config to a file object."""
         self._config.write(fh)
 
     @classmethod
-    def _format_metadata(
-        cls,
-        type_cls,
-        description,
-        default=DefaultValue,
-        extra=None,
-    ):
+    def _format_metadata(cls, type_cls, description, default=DefaultValue, extra=None):
         """Formats and returns the metadata for a setting.
 
         Each setting must have:
 
             type_cls -- a ConfigType-derived type defining the type of the setting.
 
             description -- str describing how to use the setting and where it
                 applies.
@@ -339,20 +334,17 @@ class ConfigSettings(collections.Mapping
                 there is no default.
 
             extra -- A dict of additional key/value pairs to add to the
                 setting metadata.
         """
         if isinstance(type_cls, string_types):
             type_cls = TYPE_CLASSES[type_cls]
 
-        meta = {
-            "description": description,
-            "type_cls": type_cls,
-        }
+        meta = {"description": description, "type_cls": type_cls}
 
         if default != DefaultValue:
             meta["default"] = default
 
         if extra:
             meta.update(extra)
 
         return meta
--- a/python/mach/mach/decorators.py
+++ b/python/mach/mach/decorators.py
@@ -1,16 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
 
 import argparse
 import collections
+import collections.abc
 
 from .base import MachError
 from .registrar import Registrar
 from mozbuild.base import MachCommandBase
 
 
 class _MachCommand(object):
     """Container for mach command metadata."""
@@ -146,17 +147,17 @@ def CommandProvider(cls):
             continue
 
         msg = (
             "Mach command '%s' implemented incorrectly. "
             + "Conditions argument must take a list "
             + "of functions. Found %s instead."
         )
 
-        if not isinstance(command.conditions, collections.Iterable):
+        if not isinstance(command.conditions, collections.abc.Iterable):
             msg = msg % (command.name, type(command.conditions))
             raise MachError(msg)
 
         for c in command.conditions:
             if not hasattr(c, "__call__"):
                 msg = msg % (command.name, type(c))
                 raise MachError(msg)
 
--- a/python/mach/mach/main.py
+++ b/python/mach/mach/main.py
@@ -11,17 +11,17 @@ import argparse
 import codecs
 import errno
 import imp
 import logging
 import os
 import sys
 import traceback
 import uuid
-from collections import Iterable
+from collections.abc import Iterable
 
 from six import string_types
 
 from .base import (
     CommandContext,
     MachError,
     MissingFileError,
     NoCommandError,
@@ -29,20 +29,17 @@ from .base import (
     UnrecognizedArgumentError,
     FailedCommandError,
 )
 from .config import ConfigSettings
 from .dispatcher import CommandAction
 from .logging import LoggingManager
 from .registrar import Registrar
 from .sentry import register_sentry, NoopErrorReporter
-from .telemetry import (
-    report_invocation_metrics,
-    create_telemetry_from_environment,
-)
+from .telemetry import report_invocation_metrics, create_telemetry_from_environment
 from .util import setenv, UserError
 
 SUGGEST_MACH_BUSTED_TEMPLATE = r"""
 You can invoke |./mach busted| to check if this issue is already on file. If it
 isn't, please use |./mach busted file %s| to report it. If |./mach busted| is
 misbehaving, you can also inspect the dependencies of bug 1543241.
 """.lstrip()
 
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -4,17 +4,18 @@
 
 from __future__ import absolute_import, print_function
 
 import os
 import six
 import sys
 import json
 
-from collections import Iterable, OrderedDict
+from collections.abc import Iterable
+from collections import OrderedDict
 from types import ModuleType
 
 import mozpack.path as mozpath
 
 from mozbuild.util import (
     FileAvoidWrite,
     memoized_property,
     ReadOnlyDict,
@@ -57,20 +58,17 @@ class BuildConfig(object):
 
             with open(path, "rt") as fh:
                 source = fh.read()
                 code_cache[path] = (
                     mtime,
                     compile(source, path, "exec", dont_inherit=1),
                 )
 
-        g = {
-            "__builtins__": __builtins__,
-            "__file__": path,
-        }
+        g = {"__builtins__": __builtins__, "__file__": path}
         l = {}
         try:
             exec(code_cache[path][1], g, l)
         except Exception:
             raise ConfigStatusFailure()
 
         config = BuildConfig()
 
--- a/python/mozbuild/mozbuild/makeutil.py
+++ b/python/mozbuild/mozbuild/makeutil.py
@@ -2,17 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 import re
 import six
-from collections import Iterable
+from collections.abc import Iterable
 
 
 class Makefile(object):
     """Provides an interface for writing simple makefiles
 
     Instances of this class are created, populated with rules, then
     written.
     """
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -4,16 +4,17 @@
 
 # This file contains miscellaneous utility functions that don't belong anywhere
 # in particular.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import argparse
 import collections
+import collections.abc
 import ctypes
 import difflib
 import errno
 import functools
 import hashlib
 import io
 import itertools
 import os
@@ -804,17 +805,17 @@ class HierarchicalStringList(object):
     __slots__ = ("_strings", "_children")
 
     def __init__(self):
         # Please change ContextDerivedTypedHierarchicalStringList in context.py
         # if you make changes here.
         self._strings = StrictOrderingOnAppendList()
         self._children = {}
 
-    class StringListAdaptor(collections.Sequence):
+    class StringListAdaptor(collections.abc.Sequence):
         def __init__(self, hsl):
             self._hsl = hsl
 
         def __getitem__(self, index):
             return self._hsl._strings[index]
 
         def __len__(self):
             return len(self._hsl._strings)
--- a/taskcluster/taskgraph/util/schema.py
+++ b/taskcluster/taskgraph/util/schema.py
@@ -2,16 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import re
 import pprint
 import collections
+import collections.abc
 import voluptuous
 
 from six import text_type, iteritems
 
 import taskgraph
 
 from .keyed_by import evaluate_keyed_by
 
@@ -185,17 +186,17 @@ def check_schema(schema):
                     check_identifier(path, v)
             elif not whitelisted(path):
                 raise RuntimeError(
                     "Unexpected type in YAML schema: {} @ {}".format(
                         type(k).__name__, path
                     )
                 )
 
-        if isinstance(sch, collections.Mapping):
+        if isinstance(sch, collections.abc.Mapping):
             for k, v in iteritems(sch):
                 child = "{}[{!r}]".format(path, k)
                 check_identifier(child, k)
                 iter(child, v)
         elif isinstance(sch, (list, tuple)):
             for i, v in enumerate(sch):
                 iter("{}[{}]".format(path, i), v)
         elif isinstance(sch, voluptuous.Any):
--- a/testing/mozbase/manifestparser/manifestparser/filters.py
+++ b/testing/mozbase/manifestparser/manifestparser/filters.py
@@ -7,17 +7,18 @@ A filter is a callable that accepts an i
 dictionary of values, and returns a new iterable of test objects. It is
 possible to define custom filters if the built-in ones are not enough.
 """
 
 from __future__ import absolute_import, division
 
 import itertools
 import os
-from collections import defaultdict, MutableSequence
+from collections import defaultdict
+from collections.abc import MutableSequence
 
 import six
 from six import string_types
 
 from .expression import (
     parse,
     ParseError,
 )
--- a/third_party/python/gyp/pylib/gyp/common.py
+++ b/third_party/python/gyp/pylib/gyp/common.py
@@ -1,15 +1,16 @@
 # Copyright (c) 2012 Google Inc. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
 from __future__ import with_statement
 
 import collections
+import collections.abc
 import errno
 import filecmp
 import os.path
 import re
 import tempfile
 import sys
 
 
@@ -489,17 +490,17 @@ def uniquer(seq, idfun=None):
         marker = idfun(item)
         if marker in seen: continue
         seen[marker] = 1
         result.append(item)
     return result
 
 
 # Based on http://code.activestate.com/recipes/576694/.
-class OrderedSet(collections.MutableSet):
+class OrderedSet(collections.abc.MutableSet):
   def __init__(self, iterable=None):
     self.end = end = []
     end += [None, end, end]         # sentinel node for doubly linked list
     self.map = {}                   # key --> [key, prev, next]
     if iterable is not None:
       self |= iterable
 
   def __len__(self):