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
This commit is contained in:
Emilio Cobos Álvarez 2021-07-05 17:55:41 +00:00
Родитель 9ee9a69ade
Коммит 52a85aaca1
9 изменённых файлов: 16 добавлений и 29 удалений

Просмотреть файл

@ -146,7 +146,7 @@ def reraise_attribute_error(func):
return _
class ConfigSettings(collections.Mapping):
class ConfigSettings(collections.abc.Mapping):
"""Interface for configuration settings.
This is the main interface to the configuration.
@ -192,7 +192,7 @@ class ConfigSettings(collections.Mapping):
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):
@ -317,13 +317,7 @@ class ConfigSettings(collections.Mapping):
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:
@ -344,10 +338,7 @@ class ConfigSettings(collections.Mapping):
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

Просмотреть файл

@ -151,7 +151,7 @@ def CommandProvider(cls):
+ "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)

Просмотреть файл

@ -16,7 +16,7 @@ import os
import sys
import traceback
import uuid
from collections import Iterable
from collections.abc import Iterable
from six import string_types
@ -34,10 +34,7 @@ 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"""

Просмотреть файл

@ -9,7 +9,8 @@ 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
@ -62,10 +63,7 @@ class BuildConfig(object):
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)

Просмотреть файл

@ -7,7 +7,7 @@ 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):

Просмотреть файл

@ -809,7 +809,7 @@ class HierarchicalStringList(object):
self._strings = StrictOrderingOnAppendList()
self._children = {}
class StringListAdaptor(collections.Sequence):
class StringListAdaptor(collections.abc.Sequence):
def __init__(self, hsl):
self._hsl = hsl

Просмотреть файл

@ -190,7 +190,7 @@ def check_schema(schema):
)
)
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)

Просмотреть файл

@ -12,7 +12,8 @@ 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

2
third_party/python/gyp/pylib/gyp/common.py поставляемый
Просмотреть файл

@ -494,7 +494,7 @@ def uniquer(seq, idfun=None):
# 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