# HG changeset patch # User Emilio Cobos Álvarez # Date 1625585189 0 # Node ID 2418633d529c6df00a83e973295eed0e891990a6 # Parent 0b5bfe85b344b34894f72176099da78c3849b5cc 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 diff --git a/python/mach/mach/config.py b/python/mach/mach/config.py --- a/python/mach/mach/config.py +++ b/python/mach/mach/config.py @@ -17,6 +17,7 @@ from __future__ import absolute_import, unicode_literals import collections +import collections.abc import os import sys import six @@ -144,7 +145,7 @@ return _ -class ConfigSettings(collections.Mapping): +class ConfigSettings(collections.abc.Mapping): """Interface for configuration settings. This is the main interface to the configuration. @@ -190,7 +191,7 @@ 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) @@ -312,8 +313,8 @@ self._config.write(fh) @classmethod - def _format_metadata(cls, provider, section, option, type_cls, description, - default=DefaultValue, extra=None): + def _format_metadata(cls, provider, section, option, type_cls, description, + default=DefaultValue, extra=None): """Formats and returns the metadata for a setting. Each setting must have: @@ -340,10 +340,7 @@ 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 diff --git a/python/mach/mach/decorators.py b/python/mach/mach/decorators.py --- 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.""" @@ -140,7 +141,7 @@ '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) diff --git a/python/mach/mach/main.py b/python/mach/mach/main.py --- 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, diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py --- 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, @@ -63,10 +64,7 @@ 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) diff --git a/python/mozbuild/mozbuild/makeutil.py b/python/mozbuild/mozbuild/makeutil.py --- a/python/mozbuild/mozbuild/makeutil.py +++ b/python/mozbuild/mozbuild/makeutil.py @@ -7,7 +7,7 @@ import os import re import six -from collections import Iterable +from collections.abc import Iterable class Makefile(object): diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py --- 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 @@ -782,7 +783,7 @@ self._strings = StrictOrderingOnAppendList() self._children = {} - class StringListAdaptor(collections.Sequence): + class StringListAdaptor(collections.abc.Sequence): def __init__(self, hsl): self._hsl = hsl diff --git a/taskcluster/taskgraph/util/schema.py b/taskcluster/taskgraph/util/schema.py --- a/taskcluster/taskgraph/util/schema.py +++ b/taskcluster/taskgraph/util/schema.py @@ -6,7 +6,7 @@ import re import pprint -import collections +import collections.abc import voluptuous from six import text_type, iteritems @@ -160,7 +160,7 @@ '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) diff --git a/third_party/python/gyp/pylib/gyp/common.py b/third_party/python/gyp/pylib/gyp/common.py --- 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): # HG changeset patch # User Emilio Cobos Álvarez # Date 1625657350 -7200 # Node ID 6b2a1a09cd4735386414483dd4050c25f9e58e86 # Parent d2ab10b1b1619f8e2473837ed9043ad28c842aa5 Bug 1719144 - Keep some code python2 compatible since we still run it in some windows talos jobs. MANUAL PUSH: Orange fix CLOSED TREE diff --git a/testing/mozbase/manifestparser/manifestparser/filters.py b/testing/mozbase/manifestparser/manifestparser/filters.py --- a/testing/mozbase/manifestparser/manifestparser/filters.py +++ b/testing/mozbase/manifestparser/manifestparser/filters.py @@ -12,7 +12,7 @@ import itertools import os -from collections import defaultdict, MutableSequence +from collections.abc import MutableSequence import six from six import string_types --- a/third_party/python/pyyaml/lib3/yaml/constructor.orig.py 2021-07-13 12:14:20.000000000 +0200 +++ b/third_party/python/pyyaml/lib3/yaml/constructor.py 2021-07-14 14:36:31.579176122 +0200 @@ -5,7 +5,7 @@ from .error import * from .nodes import * -import collections, datetime, base64, binascii, re, sys, types +import collections.abc, datetime, base64, binascii, re, sys, types class ConstructorError(MarkedYAMLError): pass @@ -123,7 +123,7 @@ mapping = {} for key_node, value_node in node.value: key = self.construct_object(key_node, deep=deep) - if not isinstance(key, collections.Hashable): + if not isinstance(key, collections.abc.Hashable): raise ConstructorError("while constructing a mapping", node.start_mark, "found unhashable key", key_node.start_mark) value = self.construct_object(value_node, deep=deep)