1From a88d0c8e27b48344942187c2611bb121bde9332d Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= <fzatlouk@redhat.com>
3Date: Tue, 13 Jul 2021 11:46:20 +0200
4Subject: [PATCH] Fixup compatibility of mozbuild with Python 3.10
5
6Stolen from [1]
7
8[1] https://src.fedoraproject.org/rpms/mozjs78/raw/rawhide/f/Fixup-compatibility-of-mozbuild-with-Python-3.10.patch
9
10Upstream-Status: Pending
11
12---
13 python/mach/mach/config.py                                    | 4 ++--
14 python/mach/mach/decorators.py                                | 2 +-
15 python/mozbuild/mozbuild/backend/configenvironment.py         | 3 ++-
16 python/mozbuild/mozbuild/makeutil.py                          | 2 +-
17 python/mozbuild/mozbuild/util.py                              | 2 +-
18 testing/marionette/client/marionette_driver/wait.py           | 2 +-
19 testing/mozbase/manifestparser/manifestparser/filters.py      | 3 ++-
20 testing/mozbase/versioninfo.py                                | 2 +-
21 testing/web-platform/tests/tools/manifest/vcs.py              | 2 +-
22 .../web-platform/tests/tools/third_party/h2/h2/settings.py    | 2 +-
23 .../tests/tools/third_party/html5lib/html5lib/_trie/_base.py  | 2 +-
24 .../tools/third_party/html5lib/html5lib/treebuilders/dom.py   | 2 +-
25 .../tests/tools/third_party/hyper/hyper/common/headers.py     | 2 +-
26 .../tests/tools/third_party/hyper/hyper/h2/settings.py        | 2 +-
27 .../tests/tools/third_party/hyper/hyper/http11/connection.py  | 4 ++--
28 .../third_party/hyper/hyper/packages/hyperframe/flags.py      | 2 +-
29 .../tests/tools/third_party/hyperframe/hyperframe/flags.py    | 2 +-
30 testing/web-platform/tests/tools/wptserve/wptserve/config.py  | 3 ++-
31 testing/web-platform/tests/webdriver/tests/support/sync.py    | 2 +-
32 19 files changed, 24 insertions(+), 21 deletions(-)
33
34diff --git a/python/mach/mach/config.py b/python/mach/mach/config.py
35index 7210eca82..edb4d2e93 100644
36--- a/python/mach/mach/config.py
37+++ b/python/mach/mach/config.py
38@@ -144,7 +144,7 @@ def reraise_attribute_error(func):
39     return _
40
41
42-class ConfigSettings(collections.Mapping):
43+class ConfigSettings(collections.abc.Mapping):
44     """Interface for configuration settings.
45
46     This is the main interface to the configuration.
47@@ -190,7 +190,7 @@ class ConfigSettings(collections.Mapping):
48     will result in exceptions being raised.
49     """
50
51-    class ConfigSection(collections.MutableMapping, object):
52+    class ConfigSection(collections.abc.MutableMapping, object):
53         """Represents an individual config section."""
54         def __init__(self, config, name, settings):
55             object.__setattr__(self, '_config', config)
56diff --git a/python/mach/mach/decorators.py b/python/mach/mach/decorators.py
57index 27f7f34a6..5f63271a3 100644
58--- a/python/mach/mach/decorators.py
59+++ b/python/mach/mach/decorators.py
60@@ -140,7 +140,7 @@ def CommandProvider(cls):
61               'Conditions argument must take a list ' + \
62               'of functions. Found %s instead.'
63
64-        if not isinstance(command.conditions, collections.Iterable):
65+        if not isinstance(command.conditions, collections.abc.Iterable):
66             msg = msg % (command.name, type(command.conditions))
67             raise MachError(msg)
68
69diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py
70index 20d1a9fa6..8747958bd 100644
71--- a/python/mozbuild/mozbuild/backend/configenvironment.py
72+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
73@@ -9,7 +9,8 @@ import six
74 import sys
75 import json
76
77-from collections import Iterable, OrderedDict
78+from collections import OrderedDict
79+from collections.abc import Iterable
80 from types import ModuleType
81
82 import mozpack.path as mozpath
83diff --git a/python/mozbuild/mozbuild/makeutil.py b/python/mozbuild/mozbuild/makeutil.py
84index 4da1a3b26..4ce56848c 100644
85--- a/python/mozbuild/mozbuild/makeutil.py
86+++ b/python/mozbuild/mozbuild/makeutil.py
87@@ -7,7 +7,7 @@ from __future__ import absolute_import, print_function, unicode_literals
88 import os
89 import re
90 import six
91-from collections import Iterable
92+from collections.abc import Iterable
93
94
95 class Makefile(object):
96diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
97index 044cf645c..98ed3ef52 100644
98--- a/python/mozbuild/mozbuild/util.py
99+++ b/python/mozbuild/mozbuild/util.py
100@@ -782,7 +782,7 @@ class HierarchicalStringList(object):
101         self._strings = StrictOrderingOnAppendList()
102         self._children = {}
103
104-    class StringListAdaptor(collections.Sequence):
105+    class StringListAdaptor(collections.abc.Sequence):
106         def __init__(self, hsl):
107             self._hsl = hsl
108
109diff --git a/testing/marionette/client/marionette_driver/wait.py b/testing/marionette/client/marionette_driver/wait.py
110index eeaa1e23d..c147f463f 100644
111--- a/testing/marionette/client/marionette_driver/wait.py
112+++ b/testing/marionette/client/marionette_driver/wait.py
113@@ -82,7 +82,7 @@ class Wait(object):
114
115         exceptions = []
116         if ignored_exceptions is not None:
117-            if isinstance(ignored_exceptions, collections.Iterable):
118+            if isinstance(ignored_exceptions, collections.abc.Iterable):
119                 exceptions.extend(iter(ignored_exceptions))
120             else:
121                 exceptions.append(ignored_exceptions)
122diff --git a/testing/mozbase/manifestparser/manifestparser/filters.py b/testing/mozbase/manifestparser/manifestparser/filters.py
123index 287ee033b..b1d608003 100644
124--- a/testing/mozbase/manifestparser/manifestparser/filters.py
125+++ b/testing/mozbase/manifestparser/manifestparser/filters.py
126@@ -12,7 +12,8 @@ from __future__ import absolute_import
127
128 import itertools
129 import os
130-from collections import defaultdict, MutableSequence
131+from collections import defaultdict
132+from collections.abc import MutableSequence
133
134 import six
135 from six import string_types
136diff --git a/testing/mozbase/versioninfo.py b/testing/mozbase/versioninfo.py
137index 91d1a0473..8c1680069 100755
138--- a/testing/mozbase/versioninfo.py
139+++ b/testing/mozbase/versioninfo.py
140@@ -11,7 +11,7 @@ from commit messages.
141
142 from __future__ import absolute_import, print_function
143
144-from collections import Iterable
145+from collections.abc import Iterable
146 from distutils.version import StrictVersion
147 import argparse
148 import os
149diff --git a/testing/web-platform/tests/tools/manifest/vcs.py b/testing/web-platform/tests/tools/manifest/vcs.py
150index 7c0feeb81..05ee19c7c 100644
151--- a/testing/web-platform/tests/tools/manifest/vcs.py
152+++ b/testing/web-platform/tests/tools/manifest/vcs.py
153@@ -3,7 +3,7 @@ import json
154 import os
155 import stat
156 from collections import deque
157-from collections import MutableMapping
158+from collections.abc import MutableMapping
159
160 from six import with_metaclass, PY2
161
162diff --git a/testing/web-platform/tests/tools/third_party/h2/h2/settings.py b/testing/web-platform/tests/tools/third_party/h2/h2/settings.py
163index 3da720329..e097630e9 100644
164--- a/testing/web-platform/tests/tools/third_party/h2/h2/settings.py
165+++ b/testing/web-platform/tests/tools/third_party/h2/h2/settings.py
166@@ -88,7 +88,7 @@ class ChangedSetting:
167         )
168
169
170-class Settings(collections.MutableMapping):
171+class Settings(collections.abc.MutableMapping):
172     """
173     An object that encapsulates HTTP/2 settings state.
174
175diff --git a/testing/web-platform/tests/tools/third_party/html5lib/html5lib/_trie/_base.py b/testing/web-platform/tests/tools/third_party/html5lib/html5lib/_trie/_base.py
176index a1158bbbf..a9295a2ba 100644
177--- a/testing/web-platform/tests/tools/third_party/html5lib/html5lib/_trie/_base.py
178+++ b/testing/web-platform/tests/tools/third_party/html5lib/html5lib/_trie/_base.py
179@@ -1,6 +1,6 @@
180 from __future__ import absolute_import, division, unicode_literals
181
182-from collections import Mapping
183+from collections.abc import Mapping
184
185
186 class Trie(Mapping):
187diff --git a/testing/web-platform/tests/tools/third_party/html5lib/html5lib/treebuilders/dom.py b/testing/web-platform/tests/tools/third_party/html5lib/html5lib/treebuilders/dom.py
188index dcfac220b..818a33433 100644
189--- a/testing/web-platform/tests/tools/third_party/html5lib/html5lib/treebuilders/dom.py
190+++ b/testing/web-platform/tests/tools/third_party/html5lib/html5lib/treebuilders/dom.py
191@@ -1,7 +1,7 @@
192 from __future__ import absolute_import, division, unicode_literals
193
194
195-from collections import MutableMapping
196+from collections.abc import MutableMapping
197 from xml.dom import minidom, Node
198 import weakref
199
200diff --git a/testing/web-platform/tests/tools/third_party/hyper/hyper/common/headers.py b/testing/web-platform/tests/tools/third_party/hyper/hyper/common/headers.py
201index 655a591ac..6454f550a 100644
202--- a/testing/web-platform/tests/tools/third_party/hyper/hyper/common/headers.py
203+++ b/testing/web-platform/tests/tools/third_party/hyper/hyper/common/headers.py
204@@ -10,7 +10,7 @@ import collections
205 from hyper.common.util import to_bytestring, to_bytestring_tuple
206
207
208-class HTTPHeaderMap(collections.MutableMapping):
209+class HTTPHeaderMap(collections.abc.MutableMapping):
210     """
211     A structure that contains HTTP headers.
212
213diff --git a/testing/web-platform/tests/tools/third_party/hyper/hyper/h2/settings.py b/testing/web-platform/tests/tools/third_party/hyper/hyper/h2/settings.py
214index fedc5e3c4..040afea92 100755
215--- a/testing/web-platform/tests/tools/third_party/hyper/hyper/h2/settings.py
216+++ b/testing/web-platform/tests/tools/third_party/hyper/hyper/h2/settings.py
217@@ -151,7 +151,7 @@ class ChangedSetting:
218         )
219
220
221-class Settings(collections.MutableMapping):
222+class Settings(collections.abc.MutableMapping):
223     """
224     An object that encapsulates HTTP/2 settings state.
225
226diff --git a/testing/web-platform/tests/tools/third_party/hyper/hyper/http11/connection.py b/testing/web-platform/tests/tools/third_party/hyper/hyper/http11/connection.py
227index 61361c358..a214311d2 100644
228--- a/testing/web-platform/tests/tools/third_party/hyper/hyper/http11/connection.py
229+++ b/testing/web-platform/tests/tools/third_party/hyper/hyper/http11/connection.py
230@@ -10,7 +10,7 @@ import os
231 import socket
232 import base64
233
234-from collections import Iterable, Mapping
235+from collections.abc import Iterable, Mapping
236
237 import collections
238 from hyperframe.frame import SettingsFrame
239@@ -295,7 +295,7 @@ class HTTP11Connection(object):
240                 return
241
242             # Iterables that set a specific content length.
243-            elif isinstance(body, collections.Iterable):
244+            elif isinstance(body, collections.abc.Iterable):
245                 for item in body:
246                     try:
247                         self._sock.send(item)
248diff --git a/testing/web-platform/tests/tools/third_party/hyper/hyper/packages/hyperframe/flags.py b/testing/web-platform/tests/tools/third_party/hyper/hyper/packages/hyperframe/flags.py
249index e8f630056..8f2ea689b 100644
250--- a/testing/web-platform/tests/tools/third_party/hyper/hyper/packages/hyperframe/flags.py
251+++ b/testing/web-platform/tests/tools/third_party/hyper/hyper/packages/hyperframe/flags.py
252@@ -11,7 +11,7 @@ import collections
253 Flag = collections.namedtuple("Flag", ["name", "bit"])
254
255
256-class Flags(collections.MutableSet):
257+class Flags(collections.abc.MutableSet):
258     """
259     A simple MutableSet implementation that will only accept known flags as elements.
260
261diff --git a/testing/web-platform/tests/tools/third_party/hyperframe/hyperframe/flags.py b/testing/web-platform/tests/tools/third_party/hyperframe/hyperframe/flags.py
262index 05b35017e..14c352e10 100644
263--- a/testing/web-platform/tests/tools/third_party/hyperframe/hyperframe/flags.py
264+++ b/testing/web-platform/tests/tools/third_party/hyperframe/hyperframe/flags.py
265@@ -11,7 +11,7 @@ import collections
266 Flag = collections.namedtuple("Flag", ["name", "bit"])
267
268
269-class Flags(collections.MutableSet):
270+class Flags(collections.abc.MutableSet):
271     """
272     A simple MutableSet implementation that will only accept known flags as
273     elements.
274diff --git a/testing/web-platform/tests/tools/wptserve/wptserve/config.py b/testing/web-platform/tests/tools/wptserve/wptserve/config.py
275index 7766565fe..3c1c36d6f 100644
276--- a/testing/web-platform/tests/tools/wptserve/wptserve/config.py
277+++ b/testing/web-platform/tests/tools/wptserve/wptserve/config.py
278@@ -2,7 +2,8 @@ import copy
279 import logging
280 import os
281
282-from collections import defaultdict, Mapping
283+from collections import defaultdict
284+from collections.abc import Mapping
285 from six import integer_types, iteritems, itervalues, string_types
286
287 from . import sslutils
288diff --git a/testing/web-platform/tests/webdriver/tests/support/sync.py b/testing/web-platform/tests/webdriver/tests/support/sync.py
289index 3fc77131c..8e8f6b819 100644
290--- a/testing/web-platform/tests/webdriver/tests/support/sync.py
291+++ b/testing/web-platform/tests/webdriver/tests/support/sync.py
292@@ -81,7 +81,7 @@ class Poll(object):
293
294         exceptions = []
295         if ignored_exceptions is not None:
296-            if isinstance(ignored_exceptions, collections.Iterable):
297+            if isinstance(ignored_exceptions, collections.abc.Iterable):
298                 exceptions.extend(iter(ignored_exceptions))
299             else:
300                 exceptions.append(ignored_exceptions)
301--
3022.31.1
303
304
305