blob: 5cdad93e9584a6a125bc0f242965db8bc6c378c0 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From 33a373ba41d978af60c2f0230bcba6ad27357ec8 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
3Date: Wed, 29 Jan 2020 16:25:11 +0100
4Subject: [PATCH] Port build to python3
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9* first tool of choice was 2to3
10* some parts were taken from [1] but during work it was found that this patch
11 introduces interesting effects - see hash functions. Working more on this
12 makes me guess that one has never worked...
13* Few parts were taken from upstream mirror [2]. Since they use six for porting
14 to python3 it adds us a new dependency.
15* To get a better overview what is going on or failing some additional messages
16 were added. The most verbose one is left disabled - see
17 python/mozbuild/mozbuild/configure/__init__.py / Line 310 onwards
18* major changes upstream on build are not to expect so upgrading should cause
19 little trouble and changes can be tracked by [3]
Patrick Williams213cb262021-08-07 19:21:33 -050020* some solutions are workarounds/hacks so this patch will not be accepted
21 upstream. This should not be a problem for us: once mozjs >= 68 will arrive
Andrew Geissler82c905d2020-04-13 13:39:40 -050022 we have to go to rust/cargo based build anyway.
23
24[1] https://code.foxkit.us/adelie/packages/blob/f2b5773da19ab397fbe64fd32dacc383cfe4cd77/user/mozjs/python3.patch
25[2] https://github.com/mozilla/gecko-dev
26[3] https://github.com/mozilla/gecko-dev/tree/esr60
27
Patrick Williams213cb262021-08-07 19:21:33 -050028Upstream-Status: Inappropriate [Some Hacks]
Andrew Geissler82c905d2020-04-13 13:39:40 -050029
30Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
31---
32 build/autoconf/config.status.m4 | 2 +-
33 build/moz.configure/android-ndk.configure | 4 +-
34 build/moz.configure/checks.configure | 4 +-
35 build/moz.configure/init.configure | 31 +-
36 build/moz.configure/keyfiles.configure | 4 +-
37 build/moz.configure/old.configure | 32 +-
38 build/moz.configure/toolchain.configure | 18 +-
39 build/moz.configure/util.configure | 9 +-
40 build/moz.configure/windows.configure | 10 +-
41 build/templates.mozbuild | 2 +-
42 config/MozZipFile.py | 12 +-
43 config/expandlibs.py | 6 +-
44 config/expandlibs_exec.py | 14 +-
45 config/expandlibs_gen.py | 4 +-
46 configure.py | 42 +-
47 js/src/build/moz.build | 8 +-
48 js/src/builtin/embedjs.py | 10 +-
49 js/src/configure | 2 +-
50 js/src/frontend/GenerateReservedWords.py | 6 +-
51 js/src/gc/GenerateStatsPhases.py | 4 +-
52 js/src/old-configure.in | 2 +
53 memory/build/moz.build | 8 +-
54 mozglue/build/moz.build | 22 +-
55 .../mozbuild/mozbuild/action/check_binary.py | 2 +
56 .../mozbuild/action/process_define_files.py | 4 +-
57 python/mozbuild/mozbuild/backend/base.py | 8 +-
58 python/mozbuild/mozbuild/backend/common.py | 8 +-
59 .../mozbuild/backend/configenvironment.py | 14 +-
60 .../mozbuild/mozbuild/backend/fastermake.py | 10 +-
61 .../mozbuild/backend/recursivemake.py | 181 +++----
62 python/mozbuild/mozbuild/config_status.py | 7 +-
63 .../mozbuild/mozbuild/configure/__init__.py | 83 +++-
64 .../mozbuild/configure/check_debug_ranges.py | 6 +-
65 python/mozbuild/mozbuild/configure/options.py | 24 +-
66 python/mozbuild/mozbuild/configure/util.py | 12 +-
67 .../mozbuild/mozbuild/controller/building.py | 16 +-
68 python/mozbuild/mozbuild/frontend/context.py | 89 ++--
69 python/mozbuild/mozbuild/frontend/data.py | 8 +-
70 python/mozbuild/mozbuild/frontend/emitter.py | 50 +-
71 python/mozbuild/mozbuild/frontend/reader.py | 49 +-
72 python/mozbuild/mozbuild/frontend/sandbox.py | 3 +-
73 python/mozbuild/mozbuild/jar.py | 12 +-
74 python/mozbuild/mozbuild/makeutil.py | 24 +-
75 python/mozbuild/mozbuild/mozinfo.py | 8 +-
76 python/mozbuild/mozbuild/preprocessor.py | 27 +-
77 python/mozbuild/mozbuild/shellutil.py | 6 +-
78 .../test/backend/test_recursivemake.py | 18 +-
79 .../mozbuild/test/configure/common.py | 8 +-
80 .../mozbuild/mozbuild/test/configure/lint.py | 8 +-
81 .../test/configure/test_checks_configure.py | 8 +-
82 .../test/configure/test_compile_checks.py | 4 +-
83 .../mozbuild/test/configure/test_configure.py | 244 +++++-----
84 .../mozbuild/test/configure/test_lint.py | 24 +-
85 .../test/configure/test_moz_configure.py | 32 +-
86 .../mozbuild/test/configure/test_options.py | 450 +++++++++---------
87 .../configure/test_toolchain_configure.py | 22 +-
88 .../test/configure/test_toolchain_helpers.py | 62 +--
89 .../configure/test_toolkit_moz_configure.py | 2 +-
90 .../mozbuild/test/configure/test_util.py | 8 +-
91 python/mozbuild/mozbuild/testing.py | 10 +-
92 python/mozbuild/mozbuild/util.py | 79 ++-
93 python/mozbuild/mozbuild/virtualenv.py | 6 +-
94 python/mozbuild/mozpack/chrome/manifest.py | 6 +-
95 python/mozbuild/mozpack/copier.py | 12 +-
96 python/mozbuild/mozpack/files.py | 22 +-
97 python/mozbuild/mozpack/manifests.py | 16 +-
98 python/mozbuild/mozpack/mozjar.py | 37 +-
99 .../manifestparser/manifestparser/ini.py | 13 +-
100 .../manifestparser/manifestparser.py | 24 +-
101 testing/mozbase/mozinfo/mozinfo/mozinfo.py | 26 +-
102 .../mozprocess/mozprocess/processhandler.py | 10 +-
103 third_party/python/which/which.py | 18 +-
104 72 files changed, 1081 insertions(+), 993 deletions(-)
105
106diff --git a/build/autoconf/config.status.m4 b/build/autoconf/config.status.m4
107index c75575386..543c2d682 100644
108--- a/build/autoconf/config.status.m4
109+++ b/build/autoconf/config.status.m4
110@@ -122,7 +122,7 @@ trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
111
112 dnl We're going to need [ ] for python syntax.
113 changequote(<<<, >>>)dnl
114-echo creating $CONFIG_STATUS
115+echo creating $CONFIG_STATUS in `pwd`
116
117 cat > $CONFIG_STATUS <<EOF
118
119diff --git a/build/moz.configure/android-ndk.configure b/build/moz.configure/android-ndk.configure
120index 1067b8619..3b592a237 100644
121--- a/build/moz.configure/android-ndk.configure
122+++ b/build/moz.configure/android-ndk.configure
123@@ -30,7 +30,7 @@ js_option('--with-android-version',
124
125
126 @depends('--with-android-version', min_android_version, '--help')
127-@imports(_from='__builtin__', _import='ValueError')
128+@imports(_from='builtins', _import='ValueError')
129 def android_version(value, min_version, _):
130 if not value:
131 # Someone has passed --without-android-version.
132@@ -68,7 +68,7 @@ add_old_configure_assignment('android_ndk', ndk)
133
134 @depends(ndk)
135 @checking('for android ndk version')
136-@imports(_from='__builtin__', _import='open')
137+@imports(_from='builtins', _import='open')
138 def ndk_version(ndk):
139 if not ndk:
140 # Building 'js/src' for non-Android.
141diff --git a/build/moz.configure/checks.configure b/build/moz.configure/checks.configure
142index 516652da9..11e1091c6 100644
143--- a/build/moz.configure/checks.configure
144+++ b/build/moz.configure/checks.configure
145@@ -14,7 +14,7 @@
146
147
148 @template
149-@imports(_from='__builtin__', _import='Exception')
150+@imports(_from='builtins', _import='Exception')
151 def _declare_exceptions():
152 class FatalCheckError(Exception):
153 '''An exception to throw from a function decorated with @checking.
154@@ -57,7 +57,7 @@ def checking(what, callback=None):
155 try:
156 ret = func(*args, **kwargs)
157 except FatalCheckError as e:
158- error = e.message
159+ error = str(e)
160 display_ret = callback(ret) if callback else ret
161 if display_ret is True:
162 log.info('yes')
163diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
164index 648ac2ded..4d74547d8 100644
165--- a/build/moz.configure/init.configure
166+++ b/build/moz.configure/init.configure
167@@ -14,7 +14,7 @@ option(env='DIST', nargs=1, help='DIST directory')
168
169
170 @depends('--help', 'DIST')
171-@imports(_from='__builtin__', _import='open')
172+@imports(_from='builtins', _import='open')
173 @imports(_from='os.path', _import='exists')
174 def check_build_environment(help, dist):
175 topobjdir = os.path.realpath(os.path.abspath('.'))
176@@ -65,7 +65,7 @@ def check_build_environment(help, dist):
177 # Check for CRLF line endings.
178 with open(os.path.join(topsrcdir, 'configure.py'), 'rb') as fh:
179 data = fh.read()
180- if '\r' in data:
181+ if b'\r' in data:
182 die('\n ***\n'
183 ' * The source tree appears to have Windows-style line endings.\n'
184 ' *\n'
185@@ -269,7 +269,7 @@ def early_options():
186 def early_options():
187 return set(
188 option.env
189- for option in __sandbox__._options.itervalues()
190+ for option in __sandbox__._options.values()
191 if option.env
192 )
193 return early_options
194@@ -307,15 +307,15 @@ def mozconfig_options(mozconfig, automation, help):
195 log.info(' %s' % arg)
196 helper.add(arg, origin='mozconfig', args=helper._args)
197
198- for key, value in mozconfig['env']['added'].iteritems():
199+ for key, value in mozconfig['env']['added'].items():
200 add(key, value)
201 os.environ[key] = value
202- for key, (_, value) in mozconfig['env']['modified'].iteritems():
203+ for key, (_, value) in mozconfig['env']['modified'].items():
204 add(key, value)
205 os.environ[key] = value
206- for key, value in mozconfig['vars']['added'].iteritems():
207+ for key, value in mozconfig['vars']['added'].items():
208 add(key, value)
209- for key, (_, value) in mozconfig['vars']['modified'].iteritems():
210+ for key, (_, value) in mozconfig['vars']['modified'].items():
211 add(key, value)
212
213
214@@ -353,7 +353,7 @@ option(env='PYTHON3', nargs=1, help='Python 3 interpreter (3.5 or later)')
215 @depends('PYTHON3')
216 @checking('for Python 3',
217 callback=lambda x: '%s (%s)' % (x.path, x.str_version) if x else 'no')
218-@imports(_from='__builtin__', _import='Exception')
219+@imports(_from='builtins', _import='Exception')
220 @imports(_from='mozbuild.pythonutil', _import='find_python3_executable')
221 @imports(_from='mozbuild.pythonutil', _import='python_executable_version')
222 def python3(env_python):
223@@ -377,9 +377,6 @@ def python3(env_python):
224 if not python:
225 return None
226
227- # The API returns a bytes whereas everything in configure is unicode.
228- python = python.decode('utf-8')
229-
230 return namespace(
231 path=python,
232 version=version,
233@@ -481,6 +478,8 @@ def hg_config(build_env, hg, version):
234 @imports('re')
235 def git_version(git):
236 out = check_cmd_output(git, '--version').rstrip()
237+ if isinstance(out, bytes):
238+ out = out.decode('utf-8')
239
240 match = re.search('git version (.*)$', out)
241
242@@ -551,8 +550,8 @@ option('--target', nargs=1,
243 @imports(_from='mozbuild.configure.constants', _import='Endianness')
244 @imports(_from='mozbuild.configure.constants', _import='Kernel')
245 @imports(_from='mozbuild.configure.constants', _import='OS')
246-@imports(_from='__builtin__', _import='KeyError')
247-@imports(_from='__builtin__', _import='ValueError')
248+@imports(_from='builtins', _import='KeyError')
249+@imports(_from='builtins', _import='ValueError')
250 def split_triplet(triplet, allow_unknown=False):
251 # The standard triplet is defined as
252 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
253@@ -562,6 +561,8 @@ def split_triplet(triplet, allow_unknown=False):
254 # Additionally, some may omit "unknown" when the manufacturer
255 # is not specified and emit
256 # CPU_TYPE-OPERATING_SYSTEM
257+ if isinstance(triplet, bytes):
258+ triplet = triplet.decode('utf-8')
259 parts = triplet.split('-', 2)
260 if len(parts) == 3:
261 cpu, _, os = parts
262@@ -987,7 +988,7 @@ add_old_configure_assignment('MOZ_BUILD_APP', build_project)
263 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
264 # - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
265 @depends(check_build_environment, '--help')
266-@imports(_from='__builtin__', _import='open')
267+@imports(_from='builtins', _import='open')
268 @imports('re')
269 def milestone(build_env, _):
270 milestone_path = os.path.join(build_env.topsrcdir,
271@@ -1105,7 +1106,7 @@ def enabled_in_nightly(milestone, _):
272 def all_configure_options():
273 result = []
274 previous = None
275- for option in __sandbox__._options.itervalues():
276+ for option in __sandbox__._options.values():
277 # __sandbox__._options contains items for both option.name and
278 # option.env. But it's also an OrderedDict, meaning both are
279 # consecutive.
280diff --git a/build/moz.configure/keyfiles.configure b/build/moz.configure/keyfiles.configure
281index 5d51cccea..14a35a3c6 100644
282--- a/build/moz.configure/keyfiles.configure
283+++ b/build/moz.configure/keyfiles.configure
284@@ -16,8 +16,8 @@ def keyfile(desc, default=None, help=None, callback=lambda x: x):
285
286 @depends('--with-%s-keyfile' % name)
287 @checking('for the %s key' % desc, lambda x: x and x is not no_key)
288- @imports(_from='__builtin__', _import='open')
289- @imports(_from='__builtin__', _import='IOError')
290+ @imports(_from='builtins', _import='open')
291+ @imports(_from='builtins', _import='IOError')
292 def keyfile(value):
293 if value:
294 try:
295diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure
296index 81c10b91f..29b496bae 100644
297--- a/build/moz.configure/old.configure
298+++ b/build/moz.configure/old.configure
299@@ -64,9 +64,9 @@ set_config('AUTOCONF', autoconf)
300
301 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
302 old_configure_assignments, build_project)
303-@imports(_from='__builtin__', _import='open')
304-@imports(_from='__builtin__', _import='print')
305-@imports(_from='__builtin__', _import='sorted')
306+@imports(_from='builtins', _import='open')
307+@imports(_from='builtins', _import='print')
308+@imports(_from='builtins', _import='sorted')
309 @imports('glob')
310 @imports('itertools')
311 @imports('subprocess')
312@@ -113,7 +113,7 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
313
314 # Make old-configure append to config.log, where we put our own log.
315 # This could be done with a m4 macro, but it's way easier this way
316- script = script.replace('>./config.log', '>>./config.log')
317+ script = script.replace(b'>./config.log', b'>>./config.log')
318
319 with open(old_configure, 'wb') as fh:
320 fh.write(script)
321@@ -282,8 +282,8 @@ def old_configure_options(*options):
322 '--x-includes',
323 '--x-libraries',
324 )
325-@imports(_from='__builtin__', _import='compile')
326-@imports(_from='__builtin__', _import='open')
327+@imports(_from='builtins', _import='compile')
328+@imports(_from='builtins', _import='open')
329 @imports('logging')
330 @imports('os')
331 @imports('subprocess')
332@@ -326,7 +326,7 @@ def old_configure(prepare_configure, extra_old_configure_args, all_options,
333 log.debug('Running %s', quote(*cmd))
334 if extra_env:
335 log.debug('with extra environment: %s',
336- ' '.join('%s=%s' % pair for pair in extra_env.iteritems()))
337+ ' '.join('%s=%s' % pair for pair in extra_env.items()))
338
339 # Our logging goes to config.log, the same file old.configure uses.
340 # We can't share the handle on the file, so close it. We assume nothing
341@@ -359,7 +359,7 @@ def old_configure(prepare_configure, extra_old_configure_args, all_options,
342 # Every variation of the exec() function I tried led to:
343 # SyntaxError: unqualified exec is not allowed in function 'main' it
344 # contains a nested function with free variables
345- exec code in raw_config # noqa
346+ exec(code, raw_config) # noqa
347
348 # Ensure all the flags known to old-configure appear in the
349 # @old_configure_options above.
350@@ -393,16 +393,24 @@ def set_old_configure_define(name, value):
351 @depends(old_configure)
352 @imports('types')
353 def post_old_configure(raw_config):
354+ log.info('post_old_configure started')
355+
356 for k, v in raw_config['substs']:
357 set_old_configure_config(
358- k[1:-1], v[1:-1] if isinstance(v, types.StringTypes) else v)
359+ k[1:-1], v[1:-1] if isinstance(v, str) else v)
360+
361+ log.info('post_old_configure 1 finished')
362
363- for k, v in dict(raw_config['defines']).iteritems():
364+ for k, v in dict(raw_config['defines']).items():
365 set_old_configure_define(k[1:-1], v[1:-1])
366
367+ log.info('post_old_configure 2 finished')
368+
369 set_old_configure_config('non_global_defines',
370 raw_config['non_global_defines'])
371
372+ log.info('post_old_configure 3 finished')
373+
374
375 # Assuming no other option is declared after this function, handle the
376 # env options that were injected by mozconfig_options by creating dummy
377@@ -414,6 +422,7 @@ def post_old_configure(raw_config):
378 @imports('__sandbox__')
379 @imports(_from='mozbuild.configure.options', _import='Option')
380 def remaining_mozconfig_options(_):
381+ log.info('remaining_mozconfig_options started')
382 helper = __sandbox__._helper
383 for arg in helper:
384 if helper._origins[arg] != 'mozconfig':
385@@ -422,5 +431,6 @@ def remaining_mozconfig_options(_):
386 if name.isupper() and name not in __sandbox__._options:
387 option = Option(env=name, nargs='*', help=name)
388 helper.handle(option)
389+ log.info('remaining_mozconfig_options finished')
390
391 # Please do not add anything after remaining_mozconfig_options()
392diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
393index fc640c75e..c5508dfb7 100755
394--- a/build/moz.configure/toolchain.configure
395+++ b/build/moz.configure/toolchain.configure
396@@ -391,7 +391,7 @@ def get_compiler_info(compiler, language):
397 ('CPU', CPU_preprocessor_checks),
398 ('KERNEL', kernel_preprocessor_checks),
399 ):
400- for n, (value, condition) in enumerate(preprocessor_checks.iteritems()):
401+ for n, (value, condition) in enumerate(preprocessor_checks.items()):
402 check += dedent('''\
403 #%(if)s %(condition)s
404 %%%(name)s "%(value)s"
405@@ -425,9 +425,9 @@ def get_compiler_info(compiler, language):
406 data = {}
407 for line in result.splitlines():
408 if line.startswith(b'%'):
409- k, _, v = line.partition(' ')
410- k = k.lstrip('%')
411- data[k] = v.replace(' ', '').lstrip('"').rstrip('"')
412+ k, _, v = line.partition(b' ')
413+ k = k.lstrip(b'%').decode('utf-8')
414+ data[k] = v.replace(b' ', b'').lstrip(b'"').rstrip(b'"').decode('utf-8')
415 log.debug('%s = %s', k, data[k])
416
417 try:
418@@ -551,7 +551,7 @@ def check_compiler(compiler, language, target):
419 )
420
421
422-@imports(_from='__builtin__', _import='open')
423+@imports(_from='builtins', _import='open')
424 @imports('json')
425 @imports('subprocess')
426 @imports('sys')
427@@ -606,7 +606,7 @@ def vs_major_version(value):
428
429
430 @depends(host, target, vs_major_version, check_build_environment, '--with-visual-studio-version')
431-@imports(_from='__builtin__', _import='sorted')
432+@imports(_from='builtins', _import='sorted')
433 @imports(_from='operator', _import='itemgetter')
434 @imports('platform')
435 def vc_compiler_path(host, target, vs_major_version, env, vs_release_name):
436@@ -807,7 +807,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
437 target.os != 'Android':
438 return namespace(**{
439 k: [] if k == 'flags' else v
440- for k, v in other_compiler.__dict__.iteritems()
441+ for k, v in other_compiler.__dict__.items()
442 })
443
444 # Normally, we'd use `var` instead of `_var`, but the interaction with
445@@ -1238,7 +1238,7 @@ set_config('VISIBILITY_FLAGS', visibility_flags)
446
447 @depends(c_compiler)
448 @imports('multiprocessing')
449-@imports(_from='__builtin__', _import='min')
450+@imports(_from='builtins', _import='min')
451 def pgo_flags(compiler):
452 if compiler.type in ('gcc', 'clang'):
453 return namespace(
454@@ -1517,6 +1517,8 @@ def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_e
455 gold = check_cmd_output(*detection_cmd).strip()
456 if not gold:
457 return
458+ if isinstance(gold, bytes):
459+ gold = gold.decode('utf-8')
460
461 goldFullPath = find_program(gold)
462 if goldFullPath is None:
463diff --git a/build/moz.configure/util.configure b/build/moz.configure/util.configure
464index 3284fd8b5..218813e2d 100644
465--- a/build/moz.configure/util.configure
466+++ b/build/moz.configure/util.configure
467@@ -25,7 +25,6 @@ def configure_error(message):
468 # does not.
469
470
471-@imports(_from='__builtin__', _import='unicode')
472 @imports('subprocess')
473 @imports('sys')
474 @imports(_from='mozbuild.configure.util', _import='LineIO')
475@@ -39,10 +38,10 @@ def check_cmd_output(*args, **kwargs):
476 if 'env' in kwargs:
477 normalized_env = {}
478 for k, v in kwargs['env'].items():
479- if isinstance(k, unicode):
480+ if isinstance(k, str):
481 k = k.encode('utf-8', 'strict')
482
483- if isinstance(v, unicode):
484+ if isinstance(v, str):
485 v = v.encode('utf-8', 'strict')
486
487 normalized_env[k] = v
488@@ -285,7 +284,7 @@ def unique_list(l):
489 # ('19.0', 'x64', r'C:\...\amd64\cl.exe')
490 # ('19.0', 'x86', r'C:\...\amd64_x86\cl.exe')
491 @imports(_import='_winreg', _as='winreg')
492-@imports(_from='__builtin__', _import='WindowsError')
493+@imports(_from='builtins', _import='WindowsError')
494 @imports(_from='fnmatch', _import='fnmatch')
495 def get_registry_values(pattern, get_32_and_64_bit=False):
496 def enum_helper(func, key):
497@@ -360,6 +359,8 @@ def get_registry_values(pattern, get_32_and_64_bit=False):
498 @imports(_from='mozbuild.configure.util', _import='Version', _as='_Version')
499 def Version(v):
500 'A version number that can be compared usefully.'
501+ if isinstance(v, bytes):
502+ v = v.decode('utf-8')
503 return _Version(v)
504
505 # Denotes a deprecated option. Combines option() and @depends:
506diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure
507index a5b790e3b..2b88fc447 100644
508--- a/build/moz.configure/windows.configure
509+++ b/build/moz.configure/windows.configure
510@@ -10,7 +10,7 @@ option('--with-windows-version', nargs=1, default='603',
511
512
513 @depends('--with-windows-version')
514-@imports(_from='__builtin__', _import='ValueError')
515+@imports(_from='builtins', _import='ValueError')
516 def valid_windows_version(value):
517 if not value:
518 die('Cannot build with --without-windows-version')
519@@ -50,8 +50,8 @@ def windows_sdk_dir(value, host):
520
521 @imports('os')
522 @imports('re')
523-@imports(_from='__builtin__', _import='sorted')
524-@imports(_from='__builtin__', _import='WindowsError')
525+@imports(_from='builtins', _import='sorted')
526+@imports(_from='builtins', _import='WindowsError')
527 def get_sdk_dirs(sdk, subdir):
528 def get_dirs_containing(sdk, stem, subdir):
529 base = os.path.join(sdk, stem)
530@@ -96,7 +96,7 @@ def valid_windows_sdk_dir_result(value):
531
532 @depends(c_compiler, windows_sdk_dir, valid_windows_version, 'WINDOWSSDKDIR')
533 @checking('for Windows SDK', valid_windows_sdk_dir_result)
534-@imports(_from='__builtin__', _import='sorted')
535+@imports(_from='builtins', _import='sorted')
536 @imports(_from='textwrap', _import='dedent')
537 def valid_windows_sdk_dir(compiler, windows_sdk_dir, target_version,
538 windows_sdk_dir_env):
539@@ -174,7 +174,7 @@ def valid_ucrt_sdk_dir_result(value):
540 @depends(windows_sdk_dir, 'WINDOWSSDKDIR', c_compiler)
541 @checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result)
542 @imports('os')
543-@imports(_from='__builtin__', _import='sorted')
544+@imports(_from='builtins', _import='sorted')
545 @imports(_import='mozpack.path', _as='mozpath')
546 def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, c_compiler):
547 if windows_sdk_dir_env:
548diff --git a/build/templates.mozbuild b/build/templates.mozbuild
549index 3da850ce5..ae5e410fe 100644
550--- a/build/templates.mozbuild
551+++ b/build/templates.mozbuild
552@@ -10,7 +10,7 @@ def Binary():
553 templates.'''
554
555 # Add -llog by default, since we use it all over the place.
556- if CONFIG['OS_TARGET'] == 'Android':
557+ if str(CONFIG['OS_TARGET']) == 'Android':
558 OS_LIBS += ['log']
559
560
561diff --git a/config/MozZipFile.py b/config/MozZipFile.py
562index 337fe0521..dc7add4c3 100644
563--- a/config/MozZipFile.py
564+++ b/config/MozZipFile.py
565@@ -18,7 +18,7 @@ class ZipFile(zipfile.ZipFile):
566 def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED,
567 lock = False):
568 if lock:
569- assert isinstance(file, basestring)
570+ assert isinstance(file, str)
571 self.lockfile = lock_file(file + '.lck')
572 else:
573 self.lockfile = None
574@@ -46,7 +46,7 @@ class ZipFile(zipfile.ZipFile):
575 date_time=time.localtime(time.time()))
576 zinfo.compress_type = self.compression
577 # Add some standard UNIX file access permissions (-rw-r--r--).
578- zinfo.external_attr = (0x81a4 & 0xFFFF) << 16L
579+ zinfo.external_attr = (0x81a4 & 0xFFFF) << 16
580 else:
581 zinfo = zinfo_or_arcname
582
583@@ -58,7 +58,7 @@ class ZipFile(zipfile.ZipFile):
584 # as the old, reuse the existing entry.
585
586 doSeek = False # store if we need to seek to the eof after overwriting
587- if self.NameToInfo.has_key(zinfo.filename):
588+ if zinfo.filename in self.NameToInfo:
589 # Find the last ZipInfo with our name.
590 # Last, because that's catching multiple overwrites
591 i = len(self.filelist)
592@@ -109,14 +109,14 @@ class ZipFile(zipfile.ZipFile):
593 # adjust file mode if we originally just wrote, now we rewrite
594 self.fp.close()
595 self.fp = open(self.filename, 'r+b')
596- all = map(lambda zi: (zi, True), self.filelist) + \
597- map(lambda zi: (zi, False), self._remove)
598+ all = [(zi, True) for zi in self.filelist] + \
599+ [(zi, False) for zi in self._remove]
600 all.sort(lambda l, r: cmp(l[0].header_offset, r[0].header_offset))
601 # empty _remove for multiple closes
602 self._remove = []
603
604 lengths = [all[i+1][0].header_offset - all[i][0].header_offset
605- for i in xrange(len(all)-1)]
606+ for i in range(len(all)-1)]
607 lengths.append(self.end - all[-1][0].header_offset)
608 to_pos = 0
609 for (zi, keep), length in zip(all, lengths):
610diff --git a/config/expandlibs.py b/config/expandlibs.py
611index ac06c432f..df1fed15d 100644
612--- a/config/expandlibs.py
613+++ b/config/expandlibs.py
614@@ -26,7 +26,7 @@ ${LIB_PREFIX}${ROOT}.${LIB_SUFFIX} following these rules:
615 descriptor contains. And for each of these LIBS, also apply the same
616 rules.
617 '''
618-from __future__ import with_statement
619+
620 import sys, os, errno
621 import expandlibs_config as conf
622
623@@ -36,7 +36,7 @@ def ensureParentDir(file):
624 if dir and not os.path.exists(dir):
625 try:
626 os.makedirs(dir)
627- except OSError, error:
628+ except OSError as error:
629 if error.errno != errno.EEXIST:
630 raise
631
632@@ -140,4 +140,4 @@ class ExpandArgs(list):
633 return [relativize(arg)]
634
635 if __name__ == '__main__':
636- print " ".join(ExpandArgs(sys.argv[1:]))
637+ print(" ".join(ExpandArgs(sys.argv[1:])))
638diff --git a/config/expandlibs_exec.py b/config/expandlibs_exec.py
639index df656016c..fb786a6a8 100644
640--- a/config/expandlibs_exec.py
641+++ b/config/expandlibs_exec.py
642@@ -20,7 +20,7 @@ With the --symbol-order argument, followed by a file name, it will add the
643 relevant linker options to change the order in which the linker puts the
644 symbols appear in the resulting binary. Only works for ELF targets.
645 '''
646-from __future__ import with_statement
647+
648 import sys
649 import os
650 from expandlibs import (
651@@ -304,11 +304,11 @@ class SectionFinder(object):
652 return syms
653
654 def print_command(out, args):
655- print >>out, "Executing: " + " ".join(args)
656+ print("Executing: " + " ".join(args), file=out)
657 for tmp in [f for f in args.tmp if os.path.isfile(f)]:
658- print >>out, tmp + ":"
659+ print(tmp + ":", file=out)
660 with open(tmp) as file:
661- print >>out, "".join([" " + l for l in file.readlines()])
662+ print("".join([" " + l for l in file.readlines()]), file=out)
663 out.flush()
664
665 def main(args, proc_callback=None):
666@@ -338,13 +338,13 @@ def main(args, proc_callback=None):
667 proc = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
668 if proc_callback:
669 proc_callback(proc)
670- except Exception, e:
671- print >>sys.stderr, 'error: Launching', args, ':', e
672+ except Exception as e:
673+ print('error: Launching', args, ':', e, file=sys.stderr)
674 raise e
675 (stdout, stderr) = proc.communicate()
676 if proc.returncode and not options.verbose:
677 print_command(sys.stderr, args)
678- sys.stderr.write(stdout)
679+ sys.stderr.write(stdout.decode("utf-8"))
680 sys.stderr.flush()
681 if proc.returncode:
682 return proc.returncode
683diff --git a/config/expandlibs_gen.py b/config/expandlibs_gen.py
684index b1de63cd0..dc62bd184 100644
685--- a/config/expandlibs_gen.py
686+++ b/config/expandlibs_gen.py
687@@ -5,7 +5,7 @@
688 '''Given a list of object files and library names, prints a library
689 descriptor to standard output'''
690
691-from __future__ import with_statement
692+
693 import sys
694 import os
695 import expandlibs_config as conf
696@@ -38,4 +38,4 @@ if __name__ == '__main__':
697
698 ensureParentDir(options.output)
699 with open(options.output, 'w') as outfile:
700- print >>outfile, generate(args)
701+ print(generate(args), file=outfile)
702diff --git a/configure.py b/configure.py
703index 771e34e38..bee329d7c 100644
704--- a/configure.py
705+++ b/configure.py
706@@ -2,10 +2,11 @@
707 # License, v. 2.0. If a copy of the MPL was not distributed with this
708 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
709
710-from __future__ import print_function, unicode_literals
711+
712
713 import codecs
714 import itertools
715+import logging
716 import os
717 import sys
718 import textwrap
719@@ -34,7 +35,9 @@ from mozbuild.util import (
720 def main(argv):
721 config = {}
722 sandbox = ConfigureSandbox(config, os.environ, argv)
723+ print('sandbox.run started')
724 sandbox.run(os.path.join(os.path.dirname(__file__), 'moz.configure'))
725+ print('sandbox.run finished')
726
727 if sandbox._help:
728 return 0
729@@ -56,12 +59,21 @@ def config_status(config):
730
731 sanitized_config = {}
732 sanitized_config['substs'] = {
733- k: sanitized_bools(v) for k, v in config.iteritems()
734+ k: sanitized_bools(v) for k, v in config.items()
735 if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR',
736 'ALL_CONFIGURE_PATHS')
737 }
738+
739+ # Hack around OptionValue entries unknown during compile
740+ for opt in ('BUILD_BACKENDS', 'MOZ_UI_LOCALE', 'RUSTFLAGS' ):
741+ old = sanitized_config['substs'][opt]
742+ new = []
743+ for setting in old:
744+ new.append(setting)
745+ sanitized_config['substs'][opt] = new
746+
747 sanitized_config['defines'] = {
748- k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
749+ k: sanitized_bools(v) for k, v in config['DEFINES'].items()
750 }
751 sanitized_config['non_global_defines'] = config['non_global_defines']
752 sanitized_config['topsrcdir'] = config['TOPSRCDIR']
753@@ -71,20 +83,17 @@ def config_status(config):
754 # Create config.status. Eventually, we'll want to just do the work it does
755 # here, when we're able to skip configure tests/use cached results/not rely
756 # on autoconf.
757- print("Creating config.status", file=sys.stderr)
758- encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
759- with codecs.open('config.status', 'w', encoding) as fh:
760+ logging.getLogger('moz.configure').info('Creating config.status')
761+ with codecs.open('config.status', 'w', 'utf-8') as fh:
762 fh.write(textwrap.dedent('''\
763 #!%(python)s
764- # coding=%(encoding)s
765- from __future__ import unicode_literals
766- from mozbuild.util import encode
767- encoding = '%(encoding)s'
768- ''') % {'python': config['PYTHON'], 'encoding': encoding})
769+ # coding=utf-8
770+ print("config.status started")
771+ ''') % {'python': config['PYTHON']})
772 # A lot of the build backend code is currently expecting byte
773 # strings and breaks in subtle ways with unicode strings. (bug 1296508)
774- for k, v in sanitized_config.iteritems():
775- fh.write('%s = encode(%s, encoding)\n' % (k, indented_repr(v)))
776+ for k, v in sanitized_config.items():
777+ fh.write('%s = %s\n' % (k, indented_repr(v)))
778 fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', "
779 "'non_global_defines', 'substs', 'mozconfig']")
780
781@@ -97,6 +106,9 @@ def config_status(config):
782 args = dict([(name, globals()[name]) for name in __all__])
783 config_status(**args)
784 '''))
785+ fh.write(textwrap.dedent('''
786+ print("config.status finished")
787+ '''))
788
789 partial_config = PartialConfigEnvironment(config['TOPOBJDIR'])
790 partial_config.write_vars(sanitized_config)
791@@ -116,7 +128,7 @@ def config_status(config):
792 # executable permissions.
793 os.chmod('config.status', 0o755)
794 if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
795- os.environ[b'WRITE_MOZINFO'] = b'1'
796+ os.environ['WRITE_MOZINFO'] = '1'
797 from mozbuild.config_status import config_status
798
799 # Some values in sanitized_config also have more complex types, such as
800@@ -127,7 +139,7 @@ def config_status(config):
801
802 # A lot of the build backend code is currently expecting byte strings
803 # and breaks in subtle ways with unicode strings.
804- return config_status(args=[], **encode(sanitized_config, encoding))
805+ return config_status(args=[], **sanitized_config)
806 return 0
807
808
809diff --git a/js/src/build/moz.build b/js/src/build/moz.build
810index a7f5fa4ce..856cae32d 100644
811--- a/js/src/build/moz.build
812+++ b/js/src/build/moz.build
813@@ -47,22 +47,22 @@ USE_LIBS += [
814 'zlib',
815 ]
816
817-if CONFIG['OS_ARCH'] not in ('WINNT', 'HP-UX'):
818+if str(CONFIG['OS_ARCH']) not in ('WINNT', 'HP-UX'):
819 OS_LIBS += [
820 'm',
821 ]
822
823-if CONFIG['OS_ARCH'] == 'FreeBSD':
824+if str(CONFIG['OS_ARCH']) == 'FreeBSD':
825 OS_LIBS += [
826 '-pthread',
827 ]
828
829-if CONFIG['OS_ARCH'] == 'Linux':
830+if str(CONFIG['OS_ARCH']) == 'Linux':
831 OS_LIBS += [
832 'dl',
833 ]
834
835-if CONFIG['OS_ARCH'] == 'SunOS':
836+if str(CONFIG['OS_ARCH']) == 'SunOS':
837 OS_LIBS += [
838 'posix4',
839 'dl',
840diff --git a/js/src/builtin/embedjs.py b/js/src/builtin/embedjs.py
841index ba25e71c1..d4f2de122 100644
842--- a/js/src/builtin/embedjs.py
843+++ b/js/src/builtin/embedjs.py
844@@ -36,7 +36,7 @@
845 #
846 # It uses the C preprocessor to process its inputs.
847
848-from __future__ import with_statement
849+
850 import re, sys, os, subprocess
851 import shlex
852 import which
853@@ -52,8 +52,8 @@ def ToCAsciiArray(lines):
854
855 def ToCArray(lines):
856 result = []
857- for chr in lines:
858- result.append(str(ord(chr)))
859+ for char in lines:
860+ result.append("0x%0.2X" % char)
861 return ", ".join(result)
862
863 HEADER_TEMPLATE = """\
864@@ -87,7 +87,7 @@ def embed(cxx, preprocessorOption, cppflags, msgs, sources, c_out, js_out, names
865
866 js_out.write(processed)
867 import zlib
868- compressed = zlib.compress(processed)
869+ compressed = zlib.compress(processed.encode('utf-8'))
870 data = ToCArray(compressed)
871 c_out.write(HEADER_TEMPLATE % {
872 'sources_type': 'unsigned char',
873@@ -107,7 +107,7 @@ def preprocess(cxx, preprocessorOption, source, args = []):
874 tmpOut = 'self-hosting-preprocessed.pp';
875 outputArg = shlex.split(preprocessorOption + tmpOut)
876
877- with open(tmpIn, 'wb') as input:
878+ with open(tmpIn, 'w') as input:
879 input.write(source)
880 print(' '.join(cxx + outputArg + args + [tmpIn]))
881 result = subprocess.Popen(cxx + outputArg + args + [tmpIn]).wait()
882diff --git a/js/src/configure b/js/src/configure
883index 3b3a39af3..8f5ea41d0 100755
884--- a/js/src/configure
885+++ b/js/src/configure
886@@ -24,4 +24,4 @@ export OLD_CONFIGURE="$SRCDIR"/old-configure
887
888 set -- "$@" --enable-project=js
889
890-which python2.7 > /dev/null && exec python2.7 "$TOPSRCDIR/configure.py" "$@" || exec python "$TOPSRCDIR/configure.py" "$@"
891+which python3 > /dev/null && exec python3 "$TOPSRCDIR/configure.py" "$@" || exec python "$TOPSRCDIR/configure.py" "$@"
892diff --git a/js/src/frontend/GenerateReservedWords.py b/js/src/frontend/GenerateReservedWords.py
893index 3aa2307b9..381c8e2b4 100644
894--- a/js/src/frontend/GenerateReservedWords.py
895+++ b/js/src/frontend/GenerateReservedWords.py
896@@ -80,14 +80,14 @@ def split_list_per_column(reserved_word_list, column):
897 per_column = column_dict.setdefault(word[column], [])
898 per_column.append(item)
899
900- return sorted(column_dict.items(), key=lambda (char, word): ord(char))
901+ return sorted(list(column_dict.items()), key=lambda char_word: ord(char_word[0]))
902
903 def generate_letter_switch(opt, unprocessed_columns, reserved_word_list,
904 columns=None):
905 assert(len(reserved_word_list) != 0);
906
907 if not columns:
908- columns = range(0, unprocessed_columns)
909+ columns = list(range(0, unprocessed_columns))
910
911 if len(reserved_word_list) == 1:
912 index, word = reserved_word_list[0]
913@@ -161,7 +161,7 @@ def split_list_per_length(reserved_word_list):
914 per_length = length_dict.setdefault(len(word), [])
915 per_length.append(item)
916
917- return sorted(length_dict.items(), key=lambda (length, word): length)
918+ return sorted(list(length_dict.items()), key=lambda length_word: length_word[0])
919
920 def generate_switch(opt, reserved_word_list):
921 assert(len(reserved_word_list) != 0);
922diff --git a/js/src/gc/GenerateStatsPhases.py b/js/src/gc/GenerateStatsPhases.py
923index 2daf83555..e39a26a4b 100644
924--- a/js/src/gc/GenerateStatsPhases.py
925+++ b/js/src/gc/GenerateStatsPhases.py
926@@ -267,7 +267,7 @@ def generateHeader(out):
927 #
928 # Generate PhaseKind enum.
929 #
930- phaseKindNames = map(lambda phaseKind: phaseKind.name, AllPhaseKinds)
931+ phaseKindNames = [phaseKind.name for phaseKind in AllPhaseKinds]
932 extraPhaseKinds = [
933 "NONE = LIMIT",
934 "EXPLICIT_SUSPENSION = LIMIT",
935@@ -279,7 +279,7 @@ def generateHeader(out):
936 #
937 # Generate Phase enum.
938 #
939- phaseNames = map(lambda phase: phase.name, AllPhases)
940+ phaseNames = [phase.name for phase in AllPhases]
941 extraPhases = [
942 "NONE = LIMIT",
943 "EXPLICIT_SUSPENSION = LIMIT",
944diff --git a/js/src/old-configure.in b/js/src/old-configure.in
945index 11c3d5a2e..389265404 100644
946--- a/js/src/old-configure.in
947+++ b/js/src/old-configure.in
948@@ -1884,3 +1884,5 @@ if test "$JS_STANDALONE"; then
949 fi
950
951 rm -fr confdefs* $ac_clean_files
952+echo confdefs* $ac_clean_files removed
953+echo "old-configure done"
954diff --git a/memory/build/moz.build b/memory/build/moz.build
955index e2c715271..f09ce7935 100644
956--- a/memory/build/moz.build
957+++ b/memory/build/moz.build
958@@ -30,7 +30,7 @@ else:
959 'fallback.cpp',
960 ]
961
962-if CONFIG['OS_TARGET'] == 'Darwin' and (CONFIG['MOZ_REPLACE_MALLOC'] or
963+if str(CONFIG['OS_TARGET']) == 'Darwin' and (CONFIG['MOZ_REPLACE_MALLOC'] or
964 CONFIG['MOZ_MEMORY']):
965 SOURCES += [
966 'zone.c',
967@@ -38,15 +38,15 @@ if CONFIG['OS_TARGET'] == 'Darwin' and (CONFIG['MOZ_REPLACE_MALLOC'] or
968
969 Library('memory')
970
971-if CONFIG['OS_TARGET'] == 'Android' and CONFIG['CC_TYPE'] == 'clang':
972+if str(CONFIG['OS_TARGET']) == 'Android' and str(CONFIG['CC_TYPE']) == 'clang':
973 CXXFLAGS += [
974 '-Wno-tautological-pointer-compare',
975 ]
976
977-if CONFIG['MOZ_BUILD_APP'] != 'memory':
978+if str(CONFIG['MOZ_BUILD_APP']) != 'memory':
979 FINAL_LIBRARY = 'mozglue'
980
981-if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
982+if str(CONFIG['CC_TYPE']) in ('msvc', 'clang-cl'):
983 CXXFLAGS += ['-wd4273'] # inconsistent dll linkage (bug 558163)
984
985 if CONFIG['MOZ_REPLACE_MALLOC_STATIC']:
986diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build
987index 53758485a..5e9308802 100644
988--- a/mozglue/build/moz.build
989+++ b/mozglue/build/moz.build
990@@ -9,12 +9,12 @@
991 # If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in
992 if CONFIG['JS_STANDALONE'] and not CONFIG['MOZ_MEMORY']:
993 Library('mozglue')
994-elif CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'):
995+elif str(CONFIG['OS_TARGET']) in ('WINNT', 'Darwin', 'Android'):
996 SharedLibrary('mozglue')
997 else:
998 Library('mozglue')
999
1000-if CONFIG['OS_TARGET'] == 'Android':
1001+if str(CONFIG['OS_TARGET']) == 'Android':
1002 SOURCES += [
1003 'BionicGlue.cpp',
1004 ]
1005@@ -24,14 +24,14 @@ if CONFIG['MOZ_ASAN']:
1006 'AsanOptions.cpp',
1007 ]
1008
1009-if CONFIG['OS_TARGET'] == 'WINNT':
1010+if str(CONFIG['OS_TARGET']) == 'WINNT':
1011 DEFFILE = 'mozglue.def'
1012 # We'll break the DLL blocklist if we immediately load user32.dll
1013 DELAYLOAD_DLLS += [
1014 'user32.dll',
1015 ]
1016
1017- if CONFIG['CC_TYPE'] == "msvc":
1018+ if str(CONFIG['CC_TYPE']) == "msvc":
1019 CFLAGS += ['-guard:cf']
1020 CXXFLAGS += ['-guard:cf']
1021 LDFLAGS += ['-guard:cf']
1022@@ -48,12 +48,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT']:
1023 'dummy.cpp',
1024 ]
1025
1026- if CONFIG['OS_TARGET'] == 'WINNT':
1027+ if str(CONFIG['OS_TARGET']) == 'WINNT':
1028 LOCAL_INCLUDES += [
1029 '/memory/build',
1030 ]
1031
1032- if CONFIG['CC_TYPE'] == "msvc":
1033+ if str(CONFIG['CC_TYPE']) == "msvc":
1034 SOURCES += ['WindowsCFGStatus.cpp']
1035 SOURCES += [
1036 'Authenticode.cpp',
1037@@ -85,17 +85,17 @@ if CONFIG['MOZ_WIDGET_TOOLKIT']:
1038 'WindowsDllBlocklist.h',
1039 ]
1040
1041- if CONFIG['CPU_ARCH'].startswith('x86'):
1042+ if str(CONFIG['CPU_ARCH']).startswith('x86'):
1043 SOURCES += [
1044 'SSE.cpp',
1045 ]
1046
1047- if CONFIG['CPU_ARCH'] == 'arm':
1048+ if str(CONFIG['CPU_ARCH']) == 'arm':
1049 SOURCES += [
1050 'arm.cpp',
1051 ]
1052
1053- if CONFIG['CPU_ARCH'].startswith('mips'):
1054+ if str(CONFIG['CPU_ARCH']).startswith('mips'):
1055 SOURCES += [
1056 'mips.cpp',
1057 ]
1058@@ -114,7 +114,7 @@ LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
1059
1060 LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
1061
1062-if CONFIG['OS_TARGET'] == 'Darwin':
1063+if str(CONFIG['OS_TARGET']) == 'Darwin':
1064 # On OSX 10.10.3, a dead lock happens in some cases involving dynamic
1065 # symbol resolution for symbols that jemalloc itself uses. While it
1066 # might be possible to find a way to avoid all such symbol resolutions,
1067@@ -124,7 +124,7 @@ if CONFIG['OS_TARGET'] == 'Darwin':
1068 # for TLS.
1069 LDFLAGS += ['-Wl,-bind_at_load']
1070
1071-if CONFIG['MOZ_LINKER'] and CONFIG['TARGET_CPU'] == 'arm':
1072+if CONFIG['MOZ_LINKER'] and str(CONFIG['TARGET_CPU']) == 'arm':
1073 LDFLAGS += ['-Wl,-version-script,%s/arm-eabi-filter' % SRCDIR]
1074
1075 DIST_INSTALL = True
1076diff --git a/python/mozbuild/mozbuild/action/check_binary.py b/python/mozbuild/mozbuild/action/check_binary.py
1077index 5665ef053..b696f73d6 100644
1078--- a/python/mozbuild/mozbuild/action/check_binary.py
1079+++ b/python/mozbuild/mozbuild/action/check_binary.py
1080@@ -104,6 +104,8 @@ def iter_readelf_symbols(target, binary):
1081
1082 def iter_readelf_dynamic(target, binary):
1083 for line in get_output(target['readelf'], '-d', binary):
1084+ if isinstance(line, bytes):
1085+ line=line.decode('utf-8')
1086 data = line.split(None, 2)
1087 if data and len(data) == 3 and data[0].startswith('0x'):
1088 yield data[1].rstrip(')').lstrip('('), data[2]
1089diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
1090index 563fbb8fa..c3df2869b 100644
1091--- a/python/mozbuild/mozbuild/action/process_define_files.py
1092+++ b/python/mozbuild/mozbuild/action/process_define_files.py
1093@@ -2,7 +2,7 @@
1094 # License, v. 2.0. If a copy of the MPL was not distributed with this
1095 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1096
1097-from __future__ import absolute_import, print_function, unicode_literals
1098+
1099
1100 import argparse
1101 import os
1102@@ -53,7 +53,7 @@ def process_define_file(output, input):
1103 'CONFIGURE_DEFINE_FILE')
1104 defines = '\n'.join(sorted(
1105 '#define %s %s' % (name, val)
1106- for name, val in config.defines['ALLDEFINES'].iteritems()))
1107+ for name, val in config.defines['ALLDEFINES'].items()))
1108 l = l[:m.start('cmd') - 1] \
1109 + defines + l[m.end('name'):]
1110 elif cmd == 'define':
1111diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py
1112index a8d5c94e0..7cda63475 100644
1113--- a/python/mozbuild/mozbuild/backend/base.py
1114+++ b/python/mozbuild/mozbuild/backend/base.py
1115@@ -2,7 +2,7 @@
1116 # License, v. 2.0. If a copy of the MPL was not distributed with this
1117 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1118
1119-from __future__ import absolute_import, unicode_literals
1120+
1121
1122 from abc import (
1123 ABCMeta,
1124@@ -31,7 +31,7 @@ from .configenvironment import ConfigEnvironment
1125 from mozbuild.base import ExecutionSummary
1126
1127
1128-class BuildBackend(LoggingMixin):
1129+class BuildBackend(LoggingMixin, metaclass=ABCMeta):
1130 """Abstract base class for build backends.
1131
1132 A build backend is merely a consumer of the build configuration (the output
1133@@ -39,8 +39,6 @@ class BuildBackend(LoggingMixin):
1134 is the discretion of the specific implementation.
1135 """
1136
1137- __metaclass__ = ABCMeta
1138-
1139 def __init__(self, environment):
1140 assert isinstance(environment, (ConfigEnvironment, EmptyConfig))
1141 self.populate_logger()
1142@@ -311,7 +309,7 @@ class BuildBackend(LoggingMixin):
1143 srcdir = mozpath.dirname(obj.input_path)
1144 pp.context.update({
1145 k: ' '.join(v) if isinstance(v, list) else v
1146- for k, v in obj.config.substs.iteritems()
1147+ for k, v in obj.config.substs.items()
1148 })
1149 pp.context.update(
1150 top_srcdir=obj.topsrcdir,
1151diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py
1152index d00cbbcaf..f747df446 100644
1153--- a/python/mozbuild/mozbuild/backend/common.py
1154+++ b/python/mozbuild/mozbuild/backend/common.py
1155@@ -2,7 +2,7 @@
1156 # License, v. 2.0. If a copy of the MPL was not distributed with this
1157 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1158
1159-from __future__ import absolute_import, unicode_literals
1160+
1161
1162 import json
1163 import os
1164@@ -174,7 +174,7 @@ class CommonBackend(BuildBackend):
1165 if len(self._idl_manager.idls):
1166 self._write_rust_xpidl_summary(self._idl_manager)
1167 self._handle_idl_manager(self._idl_manager)
1168- self._handle_generated_sources(mozpath.join(self.environment.topobjdir, 'dist/include/%s.h' % idl['root']) for idl in self._idl_manager.idls.values())
1169+ self._handle_generated_sources(mozpath.join(self.environment.topobjdir, 'dist/include/%s.h' % idl['root']) for idl in list(self._idl_manager.idls.values()))
1170
1171
1172 for config in self._configs:
1173@@ -372,14 +372,14 @@ class CommonBackend(BuildBackend):
1174
1175 with self._write_file(mozpath.join(topobjdir, 'dist', 'xpcrs', 'rt', 'all.rs')) as fh:
1176 fh.write("// THIS FILE IS GENERATED - DO NOT EDIT\n\n")
1177- for idl in manager.idls.values():
1178+ for idl in list(manager.idls.values()):
1179 fh.write(include_tmpl % ("rt", idl['root']))
1180 fh.write(";\n")
1181
1182 with self._write_file(mozpath.join(topobjdir, 'dist', 'xpcrs', 'bt', 'all.rs')) as fh:
1183 fh.write("// THIS FILE IS GENERATED - DO NOT EDIT\n\n")
1184 fh.write("&[\n")
1185- for idl in manager.idls.values():
1186+ for idl in list(manager.idls.values()):
1187 fh.write(include_tmpl % ("bt", idl['root']))
1188 fh.write(",\n")
1189 fh.write("]\n")
1190diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py
1191index 3676a7d18..f0896cea4 100644
1192--- a/python/mozbuild/mozbuild/backend/configenvironment.py
1193+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
1194@@ -2,14 +2,14 @@
1195 # License, v. 2.0. If a copy of the MPL was not distributed with this
1196 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1197
1198-from __future__ import absolute_import
1199+
1200
1201 import os
1202 import sys
1203 import json
1204
1205 from collections import Iterable, OrderedDict
1206-from types import StringTypes, ModuleType
1207+from types import ModuleType
1208
1209 import mozpack.path as mozpath
1210
1211@@ -22,7 +22,7 @@ from mozbuild.shellutil import quote as shell_quote
1212
1213
1214 if sys.version_info.major == 2:
1215- text_type = unicode
1216+ text_type = str
1217 else:
1218 text_type = str
1219
1220@@ -151,7 +151,7 @@ class ConfigEnvironment(object):
1221 shell_quote(self.defines[name]).replace('$', '$$'))
1222 for name in sorted(global_defines)])
1223 def serialize(name, obj):
1224- if isinstance(obj, StringTypes):
1225+ if isinstance(obj, str):
1226 return obj
1227 if isinstance(obj, Iterable):
1228 return ' '.join(obj)
1229@@ -185,8 +185,8 @@ class ConfigEnvironment(object):
1230 except UnicodeDecodeError:
1231 return v.decode('utf-8', 'replace')
1232
1233- for k, v in self.substs.items():
1234- if not isinstance(v, StringTypes):
1235+ for k, v in list(self.substs.items()):
1236+ if not isinstance(v, str):
1237 if isinstance(v, Iterable):
1238 type(v)(decode(i) for i in v)
1239 elif not isinstance(v, text_type):
1240@@ -255,7 +255,7 @@ class PartialConfigDict(object):
1241 existing_files = self._load_config_track()
1242
1243 new_files = set()
1244- for k, v in values.iteritems():
1245+ for k, v in values.items():
1246 new_files.add(self._write_file(k, v))
1247
1248 for filename in existing_files - new_files:
1249diff --git a/python/mozbuild/mozbuild/backend/fastermake.py b/python/mozbuild/mozbuild/backend/fastermake.py
1250index b029aa10f..b66ade64f 100644
1251--- a/python/mozbuild/mozbuild/backend/fastermake.py
1252+++ b/python/mozbuild/mozbuild/backend/fastermake.py
1253@@ -2,7 +2,7 @@
1254 # License, v. 2.0. If a copy of the MPL was not distributed with this
1255 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1256
1257-from __future__ import absolute_import, unicode_literals, print_function
1258+
1259
1260 from mozbuild.backend.base import PartialBackend
1261 from mozbuild.backend.common import CommonBackend
1262@@ -140,7 +140,7 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
1263 # Add information for chrome manifest generation
1264 manifest_targets = []
1265
1266- for target, entries in self._manifest_entries.iteritems():
1267+ for target, entries in self._manifest_entries.items():
1268 manifest_targets.append(target)
1269 install_target = mozpath.basedir(target, install_manifests_bases)
1270 self._install_manifests[install_target].add_content(
1271@@ -152,13 +152,13 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
1272 % ' '.join(self._install_manifests.keys()))
1273
1274 # Add dependencies we infered:
1275- for target, deps in self._dependencies.iteritems():
1276+ for target, deps in self._dependencies.items():
1277 mk.create_rule([target]).add_dependencies(
1278 '$(TOPOBJDIR)/%s' % d for d in deps)
1279
1280 mk.add_statement('include $(TOPSRCDIR)/config/faster/rules.mk')
1281
1282- for base, install_manifest in self._install_manifests.iteritems():
1283+ for base, install_manifest in self._install_manifests.items():
1284 with self._write_file(
1285 mozpath.join(self.environment.topobjdir, 'faster',
1286 'install_%s' % base.replace('/', '_'))) as fh:
1287@@ -167,7 +167,7 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
1288 # For artifact builds only, write a single unified manifest for consumption by |mach watch|.
1289 if self.environment.is_artifact_build:
1290 unified_manifest = InstallManifest()
1291- for base, install_manifest in self._install_manifests.iteritems():
1292+ for base, install_manifest in self._install_manifests.items():
1293 # Expect 'dist/bin/**', which includes 'dist/bin' with no trailing slash.
1294 assert base.startswith('dist/bin')
1295 base = base[len('dist/bin'):]
1296diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py
1297index dd9020d62..aa89cc297 100644
1298--- a/python/mozbuild/mozbuild/backend/recursivemake.py
1299+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
1300@@ -2,7 +2,7 @@
1301 # License, v. 2.0. If a copy of the MPL was not distributed with this
1302 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1303
1304-from __future__ import absolute_import, unicode_literals
1305+
1306
1307 import logging
1308 import os
1309@@ -12,7 +12,7 @@ from collections import (
1310 defaultdict,
1311 namedtuple,
1312 )
1313-from StringIO import StringIO
1314+from io import StringIO
1315 from itertools import chain
1316
1317 from mozpack.manifests import (
1318@@ -80,75 +80,76 @@ from ..util import (
1319 )
1320 from ..makeutil import Makefile
1321 from mozbuild.shellutil import quote as shell_quote
1322+from functools import reduce
1323
1324 MOZBUILD_VARIABLES = [
1325- b'ASFLAGS',
1326- b'CMSRCS',
1327- b'CMMSRCS',
1328- b'CPP_UNIT_TESTS',
1329- b'DIRS',
1330- b'DIST_INSTALL',
1331- b'EXTRA_DSO_LDOPTS',
1332- b'EXTRA_JS_MODULES',
1333- b'EXTRA_PP_COMPONENTS',
1334- b'EXTRA_PP_JS_MODULES',
1335- b'FORCE_SHARED_LIB',
1336- b'FORCE_STATIC_LIB',
1337- b'FINAL_LIBRARY',
1338- b'HOST_CFLAGS',
1339- b'HOST_CSRCS',
1340- b'HOST_CMMSRCS',
1341- b'HOST_CXXFLAGS',
1342- b'HOST_EXTRA_LIBS',
1343- b'HOST_LIBRARY_NAME',
1344- b'HOST_PROGRAM',
1345- b'HOST_SIMPLE_PROGRAMS',
1346- b'JAR_MANIFEST',
1347- b'JAVA_JAR_TARGETS',
1348- b'LIBRARY_NAME',
1349- b'LIBS',
1350- b'MAKE_FRAMEWORK',
1351- b'MODULE',
1352- b'NO_DIST_INSTALL',
1353- b'NO_EXPAND_LIBS',
1354- b'NO_INTERFACES_MANIFEST',
1355- b'NO_JS_MANIFEST',
1356- b'OS_LIBS',
1357- b'PARALLEL_DIRS',
1358- b'PREF_JS_EXPORTS',
1359- b'PROGRAM',
1360- b'RESOURCE_FILES',
1361- b'SHARED_LIBRARY_LIBS',
1362- b'SHARED_LIBRARY_NAME',
1363- b'SIMPLE_PROGRAMS',
1364- b'SONAME',
1365- b'STATIC_LIBRARY_NAME',
1366- b'TEST_DIRS',
1367- b'TOOL_DIRS',
1368+ 'ASFLAGS',
1369+ 'CMSRCS',
1370+ 'CMMSRCS',
1371+ 'CPP_UNIT_TESTS',
1372+ 'DIRS',
1373+ 'DIST_INSTALL',
1374+ 'EXTRA_DSO_LDOPTS',
1375+ 'EXTRA_JS_MODULES',
1376+ 'EXTRA_PP_COMPONENTS',
1377+ 'EXTRA_PP_JS_MODULES',
1378+ 'FORCE_SHARED_LIB',
1379+ 'FORCE_STATIC_LIB',
1380+ 'FINAL_LIBRARY',
1381+ 'HOST_CFLAGS',
1382+ 'HOST_CSRCS',
1383+ 'HOST_CMMSRCS',
1384+ 'HOST_CXXFLAGS',
1385+ 'HOST_EXTRA_LIBS',
1386+ 'HOST_LIBRARY_NAME',
1387+ 'HOST_PROGRAM',
1388+ 'HOST_SIMPLE_PROGRAMS',
1389+ 'JAR_MANIFEST',
1390+ 'JAVA_JAR_TARGETS',
1391+ 'LIBRARY_NAME',
1392+ 'LIBS',
1393+ 'MAKE_FRAMEWORK',
1394+ 'MODULE',
1395+ 'NO_DIST_INSTALL',
1396+ 'NO_EXPAND_LIBS',
1397+ 'NO_INTERFACES_MANIFEST',
1398+ 'NO_JS_MANIFEST',
1399+ 'OS_LIBS',
1400+ 'PARALLEL_DIRS',
1401+ 'PREF_JS_EXPORTS',
1402+ 'PROGRAM',
1403+ 'RESOURCE_FILES',
1404+ 'SHARED_LIBRARY_LIBS',
1405+ 'SHARED_LIBRARY_NAME',
1406+ 'SIMPLE_PROGRAMS',
1407+ 'SONAME',
1408+ 'STATIC_LIBRARY_NAME',
1409+ 'TEST_DIRS',
1410+ 'TOOL_DIRS',
1411 # XXX config/Makefile.in specifies this in a make invocation
1412 #'USE_EXTENSION_MANIFEST',
1413- b'XPCSHELL_TESTS',
1414- b'XPIDL_MODULE',
1415+ 'XPCSHELL_TESTS',
1416+ 'XPIDL_MODULE',
1417 ]
1418
1419 DEPRECATED_VARIABLES = [
1420- b'EXPORT_LIBRARY',
1421- b'EXTRA_LIBS',
1422- b'HOST_LIBS',
1423- b'LIBXUL_LIBRARY',
1424- b'MOCHITEST_A11Y_FILES',
1425- b'MOCHITEST_BROWSER_FILES',
1426- b'MOCHITEST_BROWSER_FILES_PARTS',
1427- b'MOCHITEST_CHROME_FILES',
1428- b'MOCHITEST_FILES',
1429- b'MOCHITEST_FILES_PARTS',
1430- b'MOCHITEST_METRO_FILES',
1431- b'MOCHITEST_ROBOCOP_FILES',
1432- b'MODULE_OPTIMIZE_FLAGS',
1433- b'MOZ_CHROME_FILE_FORMAT',
1434- b'SHORT_LIBNAME',
1435- b'TESTING_JS_MODULES',
1436- b'TESTING_JS_MODULE_DIR',
1437+ 'EXPORT_LIBRARY',
1438+ 'EXTRA_LIBS',
1439+ 'HOST_LIBS',
1440+ 'LIBXUL_LIBRARY',
1441+ 'MOCHITEST_A11Y_FILES',
1442+ 'MOCHITEST_BROWSER_FILES',
1443+ 'MOCHITEST_BROWSER_FILES_PARTS',
1444+ 'MOCHITEST_CHROME_FILES',
1445+ 'MOCHITEST_FILES',
1446+ 'MOCHITEST_FILES_PARTS',
1447+ 'MOCHITEST_METRO_FILES',
1448+ 'MOCHITEST_ROBOCOP_FILES',
1449+ 'MODULE_OPTIMIZE_FLAGS',
1450+ 'MOZ_CHROME_FILE_FORMAT',
1451+ 'SHORT_LIBNAME',
1452+ 'TESTING_JS_MODULES',
1453+ 'TESTING_JS_MODULE_DIR',
1454 ]
1455
1456 MOZBUILD_VARIABLES_MESSAGE = 'It should only be defined in moz.build files.'
1457@@ -207,7 +208,7 @@ class BackendMakeFile(object):
1458 self.fh.write(buf)
1459
1460 def write_once(self, buf):
1461- if isinstance(buf, unicode):
1462+ if isinstance(buf, str):
1463 buf = buf.encode('utf-8')
1464 if b'\n' + buf not in self.fh.getvalue():
1465 self.write(buf)
1466@@ -280,7 +281,7 @@ class RecursiveMakeTraversal(object):
1467 Helper function to call a filter from compute_dependencies and
1468 traverse.
1469 """
1470- return filter(current, self.get_subdirs(current))
1471+ return list(filter(current, self.get_subdirs(current)))
1472
1473 def compute_dependencies(self, filter=None):
1474 """
1475@@ -710,7 +711,7 @@ class RecursiveMakeBackend(CommonBackend):
1476 convenience variables, and the other dependency definitions for a
1477 hopefully proper directory traversal.
1478 """
1479- for tier, no_skip in self._no_skip.items():
1480+ for tier, no_skip in list(self._no_skip.items()):
1481 self.log(logging.DEBUG, 'fill_root_mk', {
1482 'number': len(no_skip), 'tier': tier
1483 }, 'Using {number} directories during {tier}')
1484@@ -757,7 +758,7 @@ class RecursiveMakeBackend(CommonBackend):
1485 for tier, filter in filters:
1486 main, all_deps = \
1487 self._traversal.compute_dependencies(filter)
1488- for dir, deps in all_deps.items():
1489+ for dir, deps in list(all_deps.items()):
1490 if deps is not None or (dir in self._idl_dirs \
1491 and tier == 'export'):
1492 rule = root_deps_mk.create_rule(['%s/%s' % (dir, tier)])
1493@@ -770,7 +771,7 @@ class RecursiveMakeBackend(CommonBackend):
1494 rule.add_dependencies('%s/%s' % (d, tier) for d in main)
1495
1496 all_compile_deps = reduce(lambda x,y: x|y,
1497- self._compile_graph.values()) if self._compile_graph else set()
1498+ list(self._compile_graph.values())) if self._compile_graph else set()
1499 # Include the following as dependencies of the top recursion target for
1500 # compilation:
1501 # - nodes that are not dependended upon by anything. Typically, this
1502@@ -783,7 +784,7 @@ class RecursiveMakeBackend(CommonBackend):
1503 # as direct dependencies of the top recursion target, to somehow
1504 # prioritize them.
1505 # 1. See bug 1262241 comment 5.
1506- compile_roots = [t for t, deps in self._compile_graph.iteritems()
1507+ compile_roots = [t for t, deps in list(self._compile_graph.items())
1508 if not deps or t not in all_compile_deps]
1509
1510 rule = root_deps_mk.create_rule(['recurse_compile'])
1511@@ -845,14 +846,14 @@ class RecursiveMakeBackend(CommonBackend):
1512 rule.add_dependencies(['$(CURDIR)/%: %'])
1513
1514 def _check_blacklisted_variables(self, makefile_in, makefile_content):
1515- if b'EXTERNALLY_MANAGED_MAKE_FILE' in makefile_content:
1516+ if 'EXTERNALLY_MANAGED_MAKE_FILE' in makefile_content:
1517 # Bypass the variable restrictions for externally managed makefiles.
1518 return
1519
1520 for l in makefile_content.splitlines():
1521 l = l.strip()
1522 # Don't check comments
1523- if l.startswith(b'#'):
1524+ if l.startswith('#'):
1525 continue
1526 for x in chain(MOZBUILD_VARIABLES, DEPRECATED_VARIABLES):
1527 if x not in l:
1528@@ -909,11 +910,11 @@ class RecursiveMakeBackend(CommonBackend):
1529 # Directories with a Makefile containing a tools target, or
1530 # XPI_PKGNAME or INSTALL_EXTENSION_ID can't be skipped and
1531 # must run during the 'tools' tier.
1532- for t in (b'XPI_PKGNAME', b'INSTALL_EXTENSION_ID',
1533- b'tools'):
1534+ for t in ('XPI_PKGNAME', 'INSTALL_EXTENSION_ID',
1535+ 'tools'):
1536 if t not in content:
1537 continue
1538- if t == b'tools' and not re.search('(?:^|\s)tools.*::', content, re.M):
1539+ if t == 'tools' and not re.search('(?:^|\s)tools.*::', content, re.M):
1540 continue
1541 if objdir == self.environment.topobjdir:
1542 continue
1543@@ -933,7 +934,7 @@ class RecursiveMakeBackend(CommonBackend):
1544 self._fill_root_mk()
1545
1546 # Make the master test manifest files.
1547- for flavor, t in self._test_manifests.items():
1548+ for flavor, t in list(self._test_manifests.items()):
1549 install_prefix, manifests = t
1550 manifest_stem = mozpath.join(install_prefix, '%s.ini' % flavor)
1551 self._write_master_test_manifest(mozpath.join(
1552@@ -1039,7 +1040,7 @@ class RecursiveMakeBackend(CommonBackend):
1553 for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done'):
1554 build_files.add_optional_exists(p)
1555
1556- for idl in manager.idls.values():
1557+ for idl in list(manager.idls.values()):
1558 self._install_manifests['dist_idl'].add_link(idl['source'],
1559 idl['basename'])
1560 self._install_manifests['dist_include'].add_optional_exists('%s.h'
1561@@ -1086,7 +1087,7 @@ class RecursiveMakeBackend(CommonBackend):
1562
1563 interfaces_manifests = []
1564 dist_dir = mozpath.join(self.environment.topobjdir, 'dist')
1565- for manifest, entries in manager.interface_manifests.items():
1566+ for manifest, entries in list(manager.interface_manifests.items()):
1567 interfaces_manifests.append(mozpath.join('$(DEPTH)', manifest))
1568 for xpt in sorted(entries):
1569 registered_xpt_files.add(mozpath.join(
1570@@ -1194,7 +1195,7 @@ class RecursiveMakeBackend(CommonBackend):
1571 # Don't allow files to be defined multiple times unless it is allowed.
1572 # We currently allow duplicates for non-test files or test files if
1573 # the manifest is listed as a duplicate.
1574- for source, (dest, is_test) in obj.installs.items():
1575+ for source, (dest, is_test) in list(obj.installs.items()):
1576 try:
1577 self._install_manifests['_test_files'].add_link(source, dest)
1578 except ValueError:
1579@@ -1558,7 +1559,7 @@ class RecursiveMakeBackend(CommonBackend):
1580 man_dir = mozpath.join(self.environment.topobjdir, '_build_manifests',
1581 dest)
1582
1583- for k, manifest in manifests.items():
1584+ for k, manifest in list(manifests.items()):
1585 with self._write_file(mozpath.join(man_dir, k)) as fh:
1586 manifest.write(fileobj=fh)
1587
1588@@ -1593,20 +1594,20 @@ class RecursiveMakeBackend(CommonBackend):
1589 pp.context.update(extra)
1590 if not pp.context.get('autoconfmk', ''):
1591 pp.context['autoconfmk'] = 'autoconf.mk'
1592- pp.handleLine(b'# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
1593- pp.handleLine(b'DEPTH := @DEPTH@\n')
1594- pp.handleLine(b'topobjdir := @topobjdir@\n')
1595- pp.handleLine(b'topsrcdir := @top_srcdir@\n')
1596- pp.handleLine(b'srcdir := @srcdir@\n')
1597- pp.handleLine(b'VPATH := @srcdir@\n')
1598- pp.handleLine(b'relativesrcdir := @relativesrcdir@\n')
1599- pp.handleLine(b'include $(DEPTH)/config/@autoconfmk@\n')
1600+ pp.handleLine('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
1601+ pp.handleLine('DEPTH := @DEPTH@\n')
1602+ pp.handleLine('topobjdir := @topobjdir@\n')
1603+ pp.handleLine('topsrcdir := @top_srcdir@\n')
1604+ pp.handleLine('srcdir := @srcdir@\n')
1605+ pp.handleLine('VPATH := @srcdir@\n')
1606+ pp.handleLine('relativesrcdir := @relativesrcdir@\n')
1607+ pp.handleLine('include $(DEPTH)/config/@autoconfmk@\n')
1608 if not stub:
1609 pp.do_include(obj.input_path)
1610 # Empty line to avoid failures when last line in Makefile.in ends
1611 # with a backslash.
1612- pp.handleLine(b'\n')
1613- pp.handleLine(b'include $(topsrcdir)/config/recurse.mk\n')
1614+ pp.handleLine('\n')
1615+ pp.handleLine('include $(topsrcdir)/config/recurse.mk\n')
1616 if not stub:
1617 # Adding the Makefile.in here has the desired side-effect
1618 # that if the Makefile.in disappears, this will force
1619diff --git a/python/mozbuild/mozbuild/config_status.py b/python/mozbuild/mozbuild/config_status.py
1620index d46f1332d..a9a27a699 100644
1621--- a/python/mozbuild/mozbuild/config_status.py
1622+++ b/python/mozbuild/mozbuild/config_status.py
1623@@ -77,6 +77,7 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
1624 See build/autoconf/config.status.m4.
1625 '''
1626
1627+ print("config_status started")
1628 if 'CONFIG_FILES' in os.environ:
1629 raise Exception('Using the CONFIG_FILES environment variable is not '
1630 'supported.')
1631@@ -119,7 +120,7 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
1632 if 'WRITE_MOZINFO' in os.environ:
1633 write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
1634
1635- cpu_start = time.clock()
1636+ cpu_start = time.perf_counter()
1637 time_start = time.time()
1638
1639 # Make appropriate backend instances, defaulting to RecursiveMakeBackend,
1640@@ -155,7 +156,7 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
1641 summary = obj.gyp_summary()
1642 print(summary, file=sys.stderr)
1643
1644- cpu_time = time.clock() - cpu_start
1645+ cpu_time = time.perf_counter() - cpu_start
1646 wall_time = time.time() - time_start
1647 efficiency = cpu_time / wall_time if wall_time else 100
1648 untracked = wall_time - execution_time
1649@@ -179,3 +180,5 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
1650 # Advertise Android Studio if it is appropriate.
1651 if MachCommandConditions.is_android(env):
1652 print(ANDROID_IDE_ADVERTISEMENT)
1653+
1654+ print("config_status finished")
1655diff --git a/python/mozbuild/mozbuild/configure/__init__.py b/python/mozbuild/mozbuild/configure/__init__.py
1656index d03615707..13d623d4f 100644
1657--- a/python/mozbuild/mozbuild/configure/__init__.py
1658+++ b/python/mozbuild/mozbuild/configure/__init__.py
1659@@ -2,9 +2,9 @@
1660 # License, v. 2.0. If a copy of the MPL was not distributed with this
1661 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1662
1663-from __future__ import absolute_import, print_function, unicode_literals
1664
1665-import __builtin__
1666+
1667+import builtins
1668 import inspect
1669 import logging
1670 import os
1671@@ -38,6 +38,8 @@ from mozbuild.util import (
1672
1673 import mozpack.path as mozpath
1674
1675+import traceback
1676+
1677
1678 class ConfigureError(Exception):
1679 pass
1680@@ -69,7 +71,7 @@ class SandboxDependsFunction(object):
1681 def __getattr__(self, key):
1682 return self._getattr(key).sandboxed
1683
1684- def __nonzero__(self):
1685+ def __bool__(self):
1686 raise ConfigureError(
1687 'Cannot do boolean operations on @depends functions.')
1688
1689@@ -96,6 +98,7 @@ class DependsFunction(object):
1690 sandbox._value_for(self)
1691 elif not sandbox._help:
1692 sandbox._execution_queue.append((sandbox._value_for, (self,)))
1693+ sandbox.tasks_debug_out("DependsFunction.__init %s" % func.__name__)
1694
1695 @property
1696 def name(self):
1697@@ -206,6 +209,15 @@ class CombinedDependsFunction(DependsFunction):
1698 def __ne__(self, other):
1699 return not self == other
1700
1701+ def __hash__(self):
1702+ # This was one was taken from [1] initially. Should not have done that:
1703+ # it causes explosion of ConfigureSandbox._execution_queue with 100%
1704+ # CPU load and eating all avaliable memory...
1705+ #
1706+ # [1] https://code.foxkit.us/adelie/packages/blob/f2b5773da19ab397fbe64fd32dacc383cfe4cd77/user/mozjs/python3.patch#L8068
1707+ return hash((self._name, tuple(self.dependencies)))
1708+
1709+
1710 class SandboxedGlobal(dict):
1711 '''Identifiable dict type for use as function global'''
1712
1713@@ -253,11 +265,12 @@ class ConfigureSandbox(dict):
1714 # The default set of builtins. We expose unicode as str to make sandboxed
1715 # files more python3-ready.
1716 BUILTINS = ReadOnlyDict({
1717- b: getattr(__builtin__, b)
1718+ b: getattr(builtins, b)
1719 for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
1720 'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
1721- 'hasattr', 'enumerate', 'range', 'zip')
1722- }, __import__=forbidden_import, str=unicode)
1723+ 'hasattr', 'enumerate', 'range', 'zip', '__build_class__',
1724+ 'bytes', 'exec')
1725+ }, __import__=forbidden_import, str=str)
1726
1727 # Expose a limited set of functions from os.path
1728 OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
1729@@ -294,6 +307,11 @@ class ConfigureSandbox(dict):
1730 # Queue of functions to execute, with their arguments
1731 self._execution_queue = []
1732
1733+ # For debugging: Show number of tasks started in run() / added elsewhere
1734+ # and some additional info
1735+ self.task_debug = False # set True to enable
1736+ self.tasks_started = 0
1737+
1738 # Store the `when`s associated to some options.
1739 self._conditions = {}
1740
1741@@ -331,7 +349,7 @@ class ConfigureSandbox(dict):
1742 return method
1743 def wrapped(*args, **kwargs):
1744 out_args = [
1745- arg.decode(encoding) if isinstance(arg, str) else arg
1746+ arg.decode(encoding) if isinstance(arg, bytes) else arg
1747 for arg in args
1748 ]
1749 return method(*out_args, **kwargs)
1750@@ -360,6 +378,14 @@ class ConfigureSandbox(dict):
1751 handler.setFormatter(formatter)
1752 logger.addHandler(handler)
1753
1754+ def tasks_debug_out(self, text):
1755+ if self.task_debug:
1756+ print("%s / queued %i / done %i" %(text, len(self._execution_queue), self.tasks_started))
1757+ #if len(self._execution_queue) > 5000:
1758+ # traceback.print_stack(file=sys.stdout)
1759+ #if len(self._execution_queue) > 5010:
1760+ # raise Exception("Too many tasks")
1761+
1762 def include_file(self, path):
1763 '''Include one file in the sandbox. Users of this class probably want
1764 to use `run` instead.
1765@@ -380,6 +406,9 @@ class ConfigureSandbox(dict):
1766 if path in self._all_paths:
1767 raise ConfigureError(
1768 'Cannot include `%s` because it was included already.' % path)
1769+
1770+ if self.task_debug:
1771+ print("include_file", path)
1772 self._paths.append(path)
1773 self._all_paths.add(path)
1774
1775@@ -398,7 +427,7 @@ class ConfigureSandbox(dict):
1776 if path:
1777 self.include_file(path)
1778
1779- for option in self._options.itervalues():
1780+ for option in self._options.values():
1781 # All options must be referenced by some @depends function
1782 if option not in self._seen:
1783 raise ConfigureError(
1784@@ -425,6 +454,8 @@ class ConfigureSandbox(dict):
1785
1786 # Run the execution queue
1787 for func, args in self._execution_queue:
1788+ self.tasks_started += 1
1789+ self.tasks_debug_out("ConfigureSandbox.run(%s)" % func.__name__)
1790 func(*args)
1791
1792 if self._help:
1793@@ -504,7 +535,7 @@ class ConfigureSandbox(dict):
1794 value = PositiveOptionValue()
1795 elif value is False or value == ():
1796 value = NegativeOptionValue()
1797- elif isinstance(value, types.StringTypes):
1798+ elif isinstance(value, (str,)):
1799 value = PositiveOptionValue((value,))
1800 elif isinstance(value, tuple):
1801 value = PositiveOptionValue(value)
1802@@ -544,7 +575,7 @@ class ConfigureSandbox(dict):
1803 return value
1804
1805 def _dependency(self, arg, callee_name, arg_name=None):
1806- if isinstance(arg, types.StringTypes):
1807+ if isinstance(arg, (str,)):
1808 prefix, name, values = Option.split_option(arg)
1809 if values != ():
1810 raise ConfigureError("Option must not contain an '='")
1811@@ -608,7 +639,7 @@ class ConfigureSandbox(dict):
1812 '''
1813 when = self._normalize_when(kwargs.get('when'), 'option')
1814 args = [self._resolve(arg) for arg in args]
1815- kwargs = {k: self._resolve(v) for k, v in kwargs.iteritems()
1816+ kwargs = {k: self._resolve(v) for k, v in kwargs.items()
1817 if k != 'when'}
1818 option = Option(*args, **kwargs)
1819 if when:
1820@@ -689,7 +720,7 @@ class ConfigureSandbox(dict):
1821 with self.only_when_impl(when):
1822 what = self._resolve(what)
1823 if what:
1824- if not isinstance(what, types.StringTypes):
1825+ if not isinstance(what, (str,)):
1826 raise TypeError("Unexpected type: '%s'" % type(what).__name__)
1827 self.include_file(what)
1828
1829@@ -707,7 +738,7 @@ class ConfigureSandbox(dict):
1830 (k[:-len('_impl')], getattr(self, k))
1831 for k in dir(self) if k.endswith('_impl') and k != 'template_impl'
1832 )
1833- glob.update((k, v) for k, v in self.iteritems() if k not in glob)
1834+ glob.update((k, v) for k, v in self.items() if k not in glob)
1835
1836 # Any function argument to the template must be prepared to be sandboxed.
1837 # If the template itself returns a function (in which case, it's very
1838@@ -731,7 +762,7 @@ class ConfigureSandbox(dict):
1839 def wrapper(*args, **kwargs):
1840 args = [maybe_prepare_function(arg) for arg in args]
1841 kwargs = {k: maybe_prepare_function(v)
1842- for k, v in kwargs.iteritems()}
1843+ for k, v in kwargs.items()}
1844 ret = template(*args, **kwargs)
1845 if isfunction(ret):
1846 # We can't expect the sandboxed code to think about all the
1847@@ -766,7 +797,7 @@ class ConfigureSandbox(dict):
1848 for value, required in (
1849 (_import, True), (_from, False), (_as, False)):
1850
1851- if not isinstance(value, types.StringTypes) and (
1852+ if not isinstance(value, (str,)) and (
1853 required or value is not None):
1854 raise TypeError("Unexpected type: '%s'" % type(value).__name__)
1855 if value is not None and not self.RE_MODULE.match(value):
1856@@ -807,7 +838,7 @@ class ConfigureSandbox(dict):
1857 # Special case for the open() builtin, because otherwise, using it
1858 # fails with "IOError: file() constructor not accessible in
1859 # restricted mode"
1860- if what == '__builtin__.open':
1861+ if what == 'builtins.open':
1862 return lambda *args, **kwargs: open(*args, **kwargs)
1863 # Until this proves to be a performance problem, just construct an
1864 # import statement and execute it.
1865@@ -829,7 +860,7 @@ class ConfigureSandbox(dict):
1866 name = self._resolve(name, need_help_dependency=False)
1867 if name is None:
1868 return
1869- if not isinstance(name, types.StringTypes):
1870+ if not isinstance(name, (str,)):
1871 raise TypeError("Unexpected type: '%s'" % type(name).__name__)
1872 if name in data:
1873 raise ConfigureError(
1874@@ -850,6 +881,7 @@ class ConfigureSandbox(dict):
1875
1876 self._execution_queue.append((
1877 self._resolve_and_set, (self._config, name, value, when)))
1878+ self.tasks_debug_out("ConfigureSandbox.set_config_impl / %s(%s" % (name, value))
1879
1880 def set_define_impl(self, name, value, when=None):
1881 '''Implementation of set_define().
1882@@ -864,6 +896,7 @@ class ConfigureSandbox(dict):
1883 defines = self._config.setdefault('DEFINES', {})
1884 self._execution_queue.append((
1885 self._resolve_and_set, (defines, name, value, when)))
1886+ self.tasks_debug_out("ConfigureSandbox.set_define_impl / %s(%s)" % (name, value))
1887
1888 def imply_option_impl(self, option, value, reason=None, when=None):
1889 '''Implementation of imply_option().
1890@@ -922,7 +955,7 @@ class ConfigureSandbox(dict):
1891 if isinstance(possible_reasons[0], Option):
1892 reason = possible_reasons[0]
1893 if not reason and (isinstance(value, (bool, tuple)) or
1894- isinstance(value, types.StringTypes)):
1895+ isinstance(value, (str,))):
1896 # A reason can be provided automatically when imply_option
1897 # is called with an immediate value.
1898 _, filename, line, _, _, _ = inspect.stack()[1]
1899@@ -955,10 +988,10 @@ class ConfigureSandbox(dict):
1900 if not inspect.isfunction(func):
1901 raise TypeError("Unexpected type: '%s'" % type(func).__name__)
1902 if func in self._prepared_functions:
1903- return func, func.func_globals
1904+ return func, func.__globals__
1905
1906 glob = SandboxedGlobal(
1907- (k, v) for k, v in func.func_globals.iteritems()
1908+ (k, v) for k, v in func.__globals__.items()
1909 if (inspect.isfunction(v) and v not in self._templates) or (
1910 inspect.isclass(v) and issubclass(v, Exception))
1911 )
1912@@ -979,20 +1012,20 @@ class ConfigureSandbox(dict):
1913 # Note this is not entirely bullet proof (if the value is e.g. a list,
1914 # the list contents could have changed), but covers the bases.
1915 closure = None
1916- if func.func_closure:
1917+ if func.__closure__:
1918 def makecell(content):
1919 def f():
1920 content
1921- return f.func_closure[0]
1922+ return f.__closure__[0]
1923
1924 closure = tuple(makecell(cell.cell_contents)
1925- for cell in func.func_closure)
1926+ for cell in func.__closure__)
1927
1928 new_func = self.wraps(func)(types.FunctionType(
1929- func.func_code,
1930+ func.__code__,
1931 glob,
1932 func.__name__,
1933- func.func_defaults,
1934+ func.__defaults__,
1935 closure
1936 ))
1937 @self.wraps(new_func)
1938diff --git a/python/mozbuild/mozbuild/configure/check_debug_ranges.py b/python/mozbuild/mozbuild/configure/check_debug_ranges.py
1939index c0caa9cc5..a3e1f37e1 100644
1940--- a/python/mozbuild/mozbuild/configure/check_debug_ranges.py
1941+++ b/python/mozbuild/mozbuild/configure/check_debug_ranges.py
1942@@ -6,7 +6,7 @@
1943 # to a given compilation unit. This is used as a helper to find a bug in some
1944 # versions of GNU ld.
1945
1946-from __future__ import absolute_import
1947+
1948
1949 import subprocess
1950 import sys
1951@@ -45,6 +45,8 @@ def get_range_length(range, debug_ranges):
1952 def main(bin, compilation_unit):
1953 p = subprocess.Popen(['objdump', '-W', bin], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
1954 (out, err) = p.communicate()
1955+ if isinstance(out, bytes):
1956+ out = out.decode('utf-8')
1957 sections = re.split('\n(Contents of the|The section) ', out)
1958 debug_info = [s for s in sections if s.startswith('.debug_info')]
1959 debug_ranges = [s for s in sections if s.startswith('.debug_ranges')]
1960@@ -59,4 +61,4 @@ def main(bin, compilation_unit):
1961
1962
1963 if __name__ == '__main__':
1964- print(main(*sys.argv[1:]))
1965+ print((main(*sys.argv[1:])))
1966diff --git a/python/mozbuild/mozbuild/configure/options.py b/python/mozbuild/mozbuild/configure/options.py
1967index 53ae2ae6d..4d80cad86 100644
1968--- a/python/mozbuild/mozbuild/configure/options.py
1969+++ b/python/mozbuild/mozbuild/configure/options.py
1970@@ -2,7 +2,7 @@
1971 # License, v. 2.0. If a copy of the MPL was not distributed with this
1972 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
1973
1974-from __future__ import absolute_import, print_function, unicode_literals
1975+
1976
1977 import os
1978 import sys
1979@@ -12,7 +12,7 @@ from collections import OrderedDict
1980
1981 def istupleofstrings(obj):
1982 return isinstance(obj, tuple) and len(obj) and all(
1983- isinstance(o, types.StringTypes) for o in obj)
1984+ isinstance(o, (str,)) for o in obj)
1985
1986
1987 class OptionValue(tuple):
1988@@ -88,7 +88,7 @@ class PositiveOptionValue(OptionValue):
1989 in the form of a tuple for when values are given to the option (in the form
1990 --option=value[,value2...].
1991 '''
1992- def __nonzero__(self):
1993+ def __bool__(self):
1994 return True
1995
1996
1997@@ -113,7 +113,7 @@ class ConflictingOptionError(InvalidOptionError):
1998 if format_data:
1999 message = message.format(**format_data)
2000 super(ConflictingOptionError, self).__init__(message)
2001- for k, v in format_data.iteritems():
2002+ for k, v in format_data.items():
2003 setattr(self, k, v)
2004
2005
2006@@ -149,7 +149,7 @@ class Option(object):
2007 'At least an option name or an environment variable name must '
2008 'be given')
2009 if name:
2010- if not isinstance(name, types.StringTypes):
2011+ if not isinstance(name, (str,)):
2012 raise InvalidOptionError('Option must be a string')
2013 if not name.startswith('--'):
2014 raise InvalidOptionError('Option must start with `--`')
2015@@ -158,7 +158,7 @@ class Option(object):
2016 if not name.islower():
2017 raise InvalidOptionError('Option must be all lowercase')
2018 if env:
2019- if not isinstance(env, types.StringTypes):
2020+ if not isinstance(env, (str,)):
2021 raise InvalidOptionError(
2022 'Environment variable name must be a string')
2023 if not env.isupper():
2024@@ -168,8 +168,8 @@ class Option(object):
2025 isinstance(nargs, int) and nargs >= 0):
2026 raise InvalidOptionError(
2027 "nargs must be a positive integer, '?', '*' or '+'")
2028- if (not isinstance(default, types.StringTypes) and
2029- not isinstance(default, (bool, types.NoneType)) and
2030+ if (not isinstance(default, (str,)) and
2031+ not isinstance(default, (bool, type(None))) and
2032 not istupleofstrings(default)):
2033 raise InvalidOptionError(
2034 'default must be a bool, a string or a tuple of strings')
2035@@ -241,7 +241,7 @@ class Option(object):
2036 ', '.join("'%s'" % c for c in choices))
2037 elif has_choices:
2038 maxargs = self.maxargs
2039- if len(choices) < maxargs and maxargs != sys.maxint:
2040+ if len(choices) < maxargs and maxargs != sys.maxsize:
2041 raise InvalidOptionError('Not enough `choices` for `nargs`')
2042 self.choices = choices
2043 self.help = help
2044@@ -255,7 +255,7 @@ class Option(object):
2045 where prefix is one of 'with', 'without', 'enable' or 'disable'.
2046 The '=values' part is optional. Values are separated with commas.
2047 '''
2048- if not isinstance(option, types.StringTypes):
2049+ if not isinstance(option, (str,)):
2050 raise InvalidOptionError('Option must be a string')
2051
2052 elements = option.split('=', 1)
2053@@ -308,7 +308,7 @@ class Option(object):
2054 def maxargs(self):
2055 if isinstance(self.nargs, int):
2056 return self.nargs
2057- return 1 if self.nargs == '?' else sys.maxint
2058+ return 1 if self.nargs == '?' else sys.maxsize
2059
2060 def _validate_nargs(self, num):
2061 minargs, maxargs = self.minargs, self.maxargs
2062@@ -499,5 +499,5 @@ class CommandLineHelper(object):
2063
2064 def __iter__(self):
2065 for d in (self._args, self._extra_args):
2066- for arg, pos in d.itervalues():
2067+ for arg, pos in d.values():
2068 yield arg
2069diff --git a/python/mozbuild/mozbuild/configure/util.py b/python/mozbuild/mozbuild/configure/util.py
2070index 9d8b2eb0e..a12986e48 100644
2071--- a/python/mozbuild/mozbuild/configure/util.py
2072+++ b/python/mozbuild/mozbuild/configure/util.py
2073@@ -77,15 +77,7 @@ class ConfigureOutputHandler(logging.Handler):
2074 # Python has this feature where it sets the encoding of pipes to
2075 # ascii, which blatantly fails when trying to print out non-ascii.
2076 def fix_encoding(fh):
2077- try:
2078- isatty = fh.isatty()
2079- except AttributeError:
2080- isatty = True
2081-
2082- if not isatty:
2083- encoding = getpreferredencoding()
2084- if encoding:
2085- return codecs.getwriter(encoding)(fh)
2086+ # no magic on oe / python3
2087 return fh
2088
2089 self._stdout = fix_encoding(stdout)
2090@@ -200,7 +192,7 @@ class LineIO(object):
2091 self._errors = errors
2092
2093 def write(self, buf):
2094- if self._encoding and isinstance(buf, str):
2095+ if self._encoding and isinstance(buf, bytes):
2096 buf = buf.decode(self._encoding, self._errors)
2097 lines = buf.splitlines()
2098 if not lines:
2099diff --git a/python/mozbuild/mozbuild/controller/building.py b/python/mozbuild/mozbuild/controller/building.py
2100index d5af532f7..e9810fe58 100644
2101--- a/python/mozbuild/mozbuild/controller/building.py
2102+++ b/python/mozbuild/mozbuild/controller/building.py
2103@@ -2,7 +2,7 @@
2104 # License, v. 2.0. If a copy of the MPL was not distributed with this
2105 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
2106
2107-from __future__ import absolute_import, unicode_literals
2108+
2109
2110 import errno
2111 import getpass
2112@@ -146,7 +146,7 @@ class TierStatus(object):
2113 """
2114 o = []
2115
2116- for tier, state in self.tiers.items():
2117+ for tier, state in list(self.tiers.items()):
2118 t_entry = dict(
2119 name=tier,
2120 start=state['begin_time'],
2121@@ -574,7 +574,7 @@ class BuildProgressFooter(Footer):
2122
2123 def __init__(self, terminal, monitor):
2124 Footer.__init__(self, terminal)
2125- self.tiers = monitor.tiers.tier_status.viewitems()
2126+ self.tiers = monitor.tiers.tier_status.items()
2127
2128 def draw(self):
2129 """Draws this footer in the terminal."""
2130@@ -911,8 +911,8 @@ class CCacheStats(object):
2131
2132 return '\n'.join(lines)
2133
2134- def __nonzero__(self):
2135- relative_values = [v for k, v in self._values.items()
2136+ def __bool__(self):
2137+ relative_values = [v for k, v in list(self._values.items())
2138 if k not in self.ABSOLUTE_KEYS]
2139 return (all(v >= 0 for v in relative_values) and
2140 any(v > 0 for v in relative_values))
2141@@ -1156,7 +1156,7 @@ class BuildDriver(MozbuildObject):
2142
2143 high_finder, finder_percent = monitor.have_high_finder_usage()
2144 if high_finder:
2145- print(FINDER_SLOW_MESSAGE % finder_percent)
2146+ print((FINDER_SLOW_MESSAGE % finder_percent))
2147
2148 ccache_end = monitor.ccache_stats()
2149
2150@@ -1276,8 +1276,8 @@ class BuildDriver(MozbuildObject):
2151 """Install test files."""
2152
2153 if self.is_clobber_needed():
2154- print(INSTALL_TESTS_CLOBBER.format(
2155- clobber_file=os.path.join(self.topobjdir, 'CLOBBER')))
2156+ print((INSTALL_TESTS_CLOBBER.format(
2157+ clobber_file=os.path.join(self.topobjdir, 'CLOBBER'))))
2158 sys.exit(1)
2159
2160 if not test_objs:
2161diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py
2162index fbdbefc1d..1aef6a65a 100644
2163--- a/python/mozbuild/mozbuild/frontend/context.py
2164+++ b/python/mozbuild/mozbuild/frontend/context.py
2165@@ -14,7 +14,7 @@ If you are looking for the absolute authority on what moz.build files can
2166 contain, you've come to the right place.
2167 """
2168
2169-from __future__ import absolute_import, unicode_literals
2170+
2171
2172 import os
2173
2174@@ -237,15 +237,15 @@ class Context(KeyedDefaultDict):
2175 This function is transactional: if setitem fails for one of the values,
2176 the context is not updated at all."""
2177 if isinstance(iterable, dict):
2178- iterable = iterable.items()
2179+ iterable = list(iterable.items())
2180
2181 update = {}
2182- for key, value in itertools.chain(iterable, kwargs.items()):
2183+ for key, value in itertools.chain(iterable, list(kwargs.items())):
2184 stored_type = self._validate(key, value)
2185 # Don't create an instance of stored_type if coercion is needed,
2186 # until all values are validated.
2187 update[key] = (value, stored_type)
2188- for key, (value, stored_type) in update.items():
2189+ for key, (value, stored_type) in list(update.items()):
2190 if not isinstance(value, stored_type):
2191 update[key] = stored_type(value)
2192 else:
2193@@ -311,7 +311,7 @@ class BaseCompileFlags(ContextDerivedValue, dict):
2194 # a template were set and which were provided as defaults.
2195 template_name = getattr(context, 'template', None)
2196 if template_name in (None, 'Gyp'):
2197- dict.__init__(self, ((k, v if v is None else TypedList(unicode)(v))
2198+ dict.__init__(self, ((k, v if v is None else TypedList(str)(v))
2199 for k, v, _ in self.flag_variables))
2200 else:
2201 dict.__init__(self)
2202@@ -520,13 +520,13 @@ class CompileFlags(BaseCompileFlags):
2203 if key in self and self[key] is None:
2204 raise ValueError('`%s` may not be set in COMPILE_FLAGS from moz.build, this '
2205 'value is resolved from the emitter.' % key)
2206- if not (isinstance(value, list) and all(isinstance(v, basestring) for v in value)):
2207+ if not (isinstance(value, list) and all(isinstance(v, str) for v in value)):
2208 raise ValueError('A list of strings must be provided as a value for a '
2209 'compile flags category.')
2210 dict.__setitem__(self, key, value)
2211
2212
2213-class FinalTargetValue(ContextDerivedValue, unicode):
2214+class FinalTargetValue(ContextDerivedValue, str):
2215 def __new__(cls, context, value=""):
2216 if not value:
2217 value = 'dist/'
2218@@ -536,7 +536,7 @@ class FinalTargetValue(ContextDerivedValue, unicode):
2219 value += 'bin'
2220 if context['DIST_SUBDIR']:
2221 value += '/' + context['DIST_SUBDIR']
2222- return unicode.__new__(cls, value)
2223+ return str.__new__(cls, value)
2224
2225
2226 def Enum(*values):
2227@@ -584,7 +584,7 @@ class PathMeta(type):
2228 cls = SourcePath
2229 return super(PathMeta, cls).__call__(context, value)
2230
2231-class Path(ContextDerivedValue, unicode):
2232+class Path(ContextDerivedValue, str, metaclass=PathMeta):
2233 """Stores and resolves a source path relative to a given context
2234
2235 This class is used as a backing type for some of the sandbox variables.
2236@@ -595,7 +595,6 @@ class Path(ContextDerivedValue, unicode):
2237 - '!objdir/relative/paths'
2238 - '%/filesystem/absolute/paths'
2239 """
2240- __metaclass__ = PathMeta
2241
2242 def __new__(cls, context, value=None):
2243 return super(Path, cls).__new__(cls, value)
2244@@ -612,10 +611,14 @@ class Path(ContextDerivedValue, unicode):
2245 """
2246 return Path(self.context, mozpath.join(self, *p))
2247
2248+ @staticmethod
2249+ def cmp(a, b):
2250+ return (a > b) - (a < b)
2251+
2252 def __cmp__(self, other):
2253 if isinstance(other, Path) and self.srcdir != other.srcdir:
2254- return cmp(self.full_path, other.full_path)
2255- return cmp(unicode(self), other)
2256+ return self.cmp(self.full_path, other.full_path)
2257+ return self.cmp(str(self), other)
2258
2259 # __cmp__ is not enough because unicode has __eq__, __ne__, etc. defined
2260 # and __cmp__ is only used for those when they don't exist.
2261@@ -773,7 +776,7 @@ def ContextDerivedTypedRecord(*fields):
2262 __slots__ = tuple([name for name, _ in fields])
2263
2264 def __init__(self, context):
2265- for fname, ftype in self._fields.items():
2266+ for fname, ftype in list(self._fields.items()):
2267 if issubclass(ftype, ContextDerivedValue):
2268 setattr(self, fname, self._fields[fname](context))
2269 else:
2270@@ -909,8 +912,8 @@ def TypedListWithAction(typ, action):
2271 return _TypedListWithAction
2272
2273 WebPlatformTestManifest = TypedNamedTuple("WebPlatformTestManifest",
2274- [("manifest_path", unicode),
2275- ("test_root", unicode)])
2276+ [("manifest_path", str),
2277+ ("test_root", str)])
2278 ManifestparserManifestList = OrderedPathListWithAction(read_manifestparser_manifest)
2279 ReftestManifestList = OrderedPathListWithAction(read_reftest_manifest)
2280 WptManifestList = TypedListWithAction(WebPlatformTestManifest, read_wpt_manifest)
2281@@ -918,18 +921,18 @@ WptManifestList = TypedListWithAction(WebPlatformTestManifest, read_wpt_manifest
2282 OrderedSourceList = ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList)
2283 OrderedTestFlavorList = TypedList(Enum(*all_test_flavors()),
2284 StrictOrderingOnAppendList)
2285-OrderedStringList = TypedList(unicode, StrictOrderingOnAppendList)
2286+OrderedStringList = TypedList(str, StrictOrderingOnAppendList)
2287 DependentTestsEntry = ContextDerivedTypedRecord(('files', OrderedSourceList),
2288 ('tags', OrderedStringList),
2289 ('flavors', OrderedTestFlavorList))
2290 BugzillaComponent = TypedNamedTuple('BugzillaComponent',
2291- [('product', unicode), ('component', unicode)])
2292+ [('product', str), ('component', str)])
2293 SchedulingComponents = ContextDerivedTypedRecord(
2294- ('inclusive', TypedList(unicode, StrictOrderingOnAppendList)),
2295- ('exclusive', TypedList(unicode, StrictOrderingOnAppendList)))
2296+ ('inclusive', TypedList(str, StrictOrderingOnAppendList)),
2297+ ('exclusive', TypedList(str, StrictOrderingOnAppendList)))
2298
2299 GeneratedFilesList = StrictOrderingOnAppendListWithFlagsFactory({
2300- 'script': unicode,
2301+ 'script': str,
2302 'inputs': list,
2303 'flags': list, })
2304
2305@@ -1096,7 +1099,7 @@ class Files(SubContext):
2306 self.test_tags |= other.test_tags
2307 self.test_flavors |= other.test_flavors
2308
2309- for k, v in other.items():
2310+ for k, v in list(other.items()):
2311 if k == 'IMPACTED_TESTS':
2312 self.test_files |= set(mozpath.relpath(e.full_path, e.context.config.topsrcdir)
2313 for e in v.files)
2314@@ -1154,7 +1157,7 @@ class Files(SubContext):
2315
2316 bug_components = Counter()
2317
2318- for f in files.values():
2319+ for f in list(files.values()):
2320 bug_component = f.get('BUG_COMPONENT')
2321 if bug_component:
2322 bug_components[bug_component] += 1
2323@@ -1232,7 +1235,7 @@ VARIABLES = {
2324 RustLibrary template instead.
2325 """),
2326
2327- 'RUST_LIBRARY_TARGET_DIR': (unicode, unicode,
2328+ 'RUST_LIBRARY_TARGET_DIR': (str, str,
2329 """Where CARGO_TARGET_DIR should point when compiling this library. If
2330 not set, it defaults to the current objdir. It should be a relative path
2331 to the current objdir; absolute paths should not be used.
2332@@ -1248,7 +1251,7 @@ VARIABLES = {
2333 HostRustLibrary template instead.
2334 """),
2335
2336- 'RUST_TEST': (unicode, unicode,
2337+ 'RUST_TEST': (str, str,
2338 """Name of a Rust test to build and run via `cargo test`.
2339
2340 This variable should not be used directly; you should be using the
2341@@ -1487,7 +1490,7 @@ VARIABLES = {
2342 """Like ``OBJDIR_FILES``, with preprocessing. Use sparingly.
2343 """),
2344
2345- 'FINAL_LIBRARY': (unicode, unicode,
2346+ 'FINAL_LIBRARY': (str, str,
2347 """Library in which the objects of the current directory will be linked.
2348
2349 This variable contains the name of a library, defined elsewhere with
2350@@ -1528,7 +1531,7 @@ VARIABLES = {
2351 with the host compiler.
2352 """),
2353
2354- 'HOST_LIBRARY_NAME': (unicode, unicode,
2355+ 'HOST_LIBRARY_NAME': (str, str,
2356 """Name of target library generated when cross compiling.
2357 """),
2358
2359@@ -1546,7 +1549,7 @@ VARIABLES = {
2360 libraries that link into this library via FINAL_LIBRARY.
2361 """),
2362
2363- 'LIBRARY_NAME': (unicode, unicode,
2364+ 'LIBRARY_NAME': (str, str,
2365 """The code name of the library generated for a directory.
2366
2367 By default STATIC_LIBRARY_NAME and SHARED_LIBRARY_NAME take this name.
2368@@ -1558,7 +1561,7 @@ VARIABLES = {
2369 ``example/components/xpcomsample.lib`` on Windows.
2370 """),
2371
2372- 'SHARED_LIBRARY_NAME': (unicode, unicode,
2373+ 'SHARED_LIBRARY_NAME': (str, str,
2374 """The name of the static library generated for a directory, if it needs to
2375 differ from the library code name.
2376
2377@@ -1572,7 +1575,7 @@ VARIABLES = {
2378 Implies FORCE_SHARED_LIB.
2379 """),
2380
2381- 'STATIC_LIBRARY_NAME': (unicode, unicode,
2382+ 'STATIC_LIBRARY_NAME': (str, str,
2383 """The name of the static library generated for a directory, if it needs to
2384 differ from the library code name.
2385
2386@@ -1604,31 +1607,31 @@ VARIABLES = {
2387
2388 This variable contains a list of system libaries to link against.
2389 """),
2390- 'RCFILE': (unicode, unicode,
2391+ 'RCFILE': (str, str,
2392 """The program .rc file.
2393
2394 This variable can only be used on Windows.
2395 """),
2396
2397- 'RESFILE': (unicode, unicode,
2398+ 'RESFILE': (str, str,
2399 """The program .res file.
2400
2401 This variable can only be used on Windows.
2402 """),
2403
2404- 'RCINCLUDE': (unicode, unicode,
2405+ 'RCINCLUDE': (str, str,
2406 """The resource script file to be included in the default .res file.
2407
2408 This variable can only be used on Windows.
2409 """),
2410
2411- 'DEFFILE': (unicode, unicode,
2412+ 'DEFFILE': (str, str,
2413 """The program .def (module definition) file.
2414
2415 This variable can only be used on Windows.
2416 """),
2417
2418- 'SYMBOLS_FILE': (Path, unicode,
2419+ 'SYMBOLS_FILE': (Path, str,
2420 """A file containing a list of symbols to export from a shared library.
2421
2422 The given file contains a list of symbols to be exported, and is
2423@@ -1649,7 +1652,7 @@ VARIABLES = {
2424 ``BIN_SUFFIX``, the name will remain unchanged.
2425 """),
2426
2427- 'SONAME': (unicode, unicode,
2428+ 'SONAME': (str, str,
2429 """The soname of the shared object currently being linked
2430
2431 soname is the "logical name" of a shared object, often used to provide
2432@@ -1719,7 +1722,7 @@ VARIABLES = {
2433 ``GENERATED_FILES``.
2434 """),
2435
2436- 'PROGRAM' : (unicode, unicode,
2437+ 'PROGRAM' : (str, str,
2438 """Compiled executable name.
2439
2440 If the configuration token ``BIN_SUFFIX`` is set, its value will be
2441@@ -1727,7 +1730,7 @@ VARIABLES = {
2442 ``BIN_SUFFIX``, ``PROGRAM`` will remain unchanged.
2443 """),
2444
2445- 'HOST_PROGRAM' : (unicode, unicode,
2446+ 'HOST_PROGRAM' : (str, str,
2447 """Compiled host executable name.
2448
2449 If the configuration token ``HOST_BIN_SUFFIX`` is set, its value will be
2450@@ -1765,7 +1768,7 @@ VARIABLES = {
2451 files.
2452 """),
2453
2454- 'XPIDL_MODULE': (unicode, unicode,
2455+ 'XPIDL_MODULE': (str, str,
2456 """XPCOM Interface Definition Module Name.
2457
2458 This is the name of the ``.xpt`` file that is created by linking
2459@@ -1924,14 +1927,14 @@ VARIABLES = {
2460
2461
2462 # The following variables are used to control the target of installed files.
2463- 'XPI_NAME': (unicode, unicode,
2464+ 'XPI_NAME': (str, str,
2465 """The name of an extension XPI to generate.
2466
2467 When this variable is present, the results of this directory will end up
2468 being packaged into an extension instead of the main dist/bin results.
2469 """),
2470
2471- 'DIST_SUBDIR': (unicode, unicode,
2472+ 'DIST_SUBDIR': (str, str,
2473 """The name of an alternate directory to install files to.
2474
2475 When this variable is present, the results of this directory will end up
2476@@ -1939,7 +1942,7 @@ VARIABLES = {
2477 otherwise be placed.
2478 """),
2479
2480- 'FINAL_TARGET': (FinalTargetValue, unicode,
2481+ 'FINAL_TARGET': (FinalTargetValue, str,
2482 """The name of the directory to install targets to.
2483
2484 The directory is relative to the top of the object directory. The
2485@@ -1970,7 +1973,7 @@ VARIABLES = {
2486
2487 'GYP_DIRS': (StrictOrderingOnAppendListWithFlagsFactory({
2488 'variables': dict,
2489- 'input': unicode,
2490+ 'input': str,
2491 'sandbox_vars': dict,
2492 'no_chromium': bool,
2493 'no_unified': bool,
2494@@ -2194,7 +2197,7 @@ VARIABLES = {
2495 }
2496
2497 # Sanity check: we don't want any variable above to have a list as storage type.
2498-for name, (storage_type, input_types, docs) in VARIABLES.items():
2499+for name, (storage_type, input_types, docs) in list(VARIABLES.items()):
2500 if storage_type == list:
2501 raise RuntimeError('%s has a "list" storage type. Use "List" instead.'
2502 % name)
2503diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py
2504index 442fc9e0a..837453a9f 100644
2505--- a/python/mozbuild/mozbuild/frontend/data.py
2506+++ b/python/mozbuild/mozbuild/frontend/data.py
2507@@ -15,7 +15,7 @@ contains the code for converting executed mozbuild files into these data
2508 structures.
2509 """
2510
2511-from __future__ import absolute_import, unicode_literals
2512+
2513
2514 from mozbuild.util import StrictOrderingOnAppendList
2515 from mozpack.chrome.manifest import ManifestEntry
2516@@ -182,7 +182,7 @@ class ComputedFlags(ContextDerived):
2517 if value:
2518 for dest_var in dest_vars:
2519 flags[dest_var].extend(value)
2520- return flags.items()
2521+ return list(flags.items())
2522
2523 class XPIDLFile(ContextDerived):
2524 """Describes an XPIDL file to be compiled."""
2525@@ -213,7 +213,7 @@ class BaseDefines(ContextDerived):
2526 self.defines = defines
2527
2528 def get_defines(self):
2529- for define, value in self.defines.iteritems():
2530+ for define, value in self.defines.items():
2531 if value is True:
2532 yield('-D%s' % define)
2533 elif value is False:
2534@@ -494,7 +494,7 @@ class SimpleProgram(BaseProgram):
2535 KIND = 'target'
2536
2537 def source_files(self):
2538- for srcs in self.sources.values():
2539+ for srcs in list(self.sources.values()):
2540 for f in srcs:
2541 if mozpath.basename(mozpath.splitext(f)[0]) == mozpath.splitext(self.program)[0]:
2542 return [f]
2543diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py
2544index 642b381c0..c28344a75 100644
2545--- a/python/mozbuild/mozbuild/frontend/emitter.py
2546+++ b/python/mozbuild/mozbuild/frontend/emitter.py
2547@@ -2,7 +2,7 @@
2548 # License, v. 2.0. If a copy of the MPL was not distributed with this
2549 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
2550
2551-from __future__ import absolute_import, unicode_literals
2552+
2553
2554 import itertools
2555 import logging
2556@@ -116,8 +116,8 @@ class TreeMetadataEmitter(LoggingMixin):
2557 # arguments. This gross hack works around the problem until we
2558 # rid ourselves of 2.6.
2559 self.info = {}
2560- for k, v in mozinfo.info.items():
2561- if isinstance(k, unicode):
2562+ for k, v in list(mozinfo.info.items()):
2563+ if isinstance(k, str):
2564 k = k.encode('ascii')
2565 self.info[k] = v
2566
2567@@ -234,7 +234,7 @@ class TreeMetadataEmitter(LoggingMixin):
2568
2569
2570 # Next do FINAL_LIBRARY linkage.
2571- for lib in (l for libs in self._libs.values() for l in libs):
2572+ for lib in (l for libs in list(self._libs.values()) for l in libs):
2573 if not isinstance(lib, (StaticLibrary, RustLibrary)) or not lib.link_into:
2574 continue
2575 if lib.link_into not in self._libs:
2576@@ -294,13 +294,13 @@ class TreeMetadataEmitter(LoggingMixin):
2577 lib.link_into == outerlib.basename):
2578 propagate_defines(lib, defines)
2579
2580- for lib in (l for libs in self._libs.values() for l in libs):
2581+ for lib in (l for libs in list(self._libs.values()) for l in libs):
2582 if isinstance(lib, Library):
2583 propagate_defines(lib, lib.lib_defines)
2584 yield lib
2585
2586
2587- for lib in (l for libs in self._libs.values() for l in libs):
2588+ for lib in (l for libs in list(self._libs.values()) for l in libs):
2589 lib_defines = list(lib.lib_defines.get_defines())
2590 if lib_defines:
2591 objdir_flags = self._compile_flags[lib.objdir]
2592@@ -310,13 +310,13 @@ class TreeMetadataEmitter(LoggingMixin):
2593 if objdir_flags:
2594 objdir_flags.resolve_flags('LIBRARY_DEFINES', lib_defines)
2595
2596- for flags_obj in self._compile_flags.values():
2597+ for flags_obj in list(self._compile_flags.values()):
2598 yield flags_obj
2599
2600- for flags_obj in self._compile_as_flags.values():
2601+ for flags_obj in list(self._compile_as_flags.values()):
2602 yield flags_obj
2603
2604- for obj in self._binaries.values():
2605+ for obj in list(self._binaries.values()):
2606 yield obj
2607
2608
2609@@ -409,7 +409,7 @@ class TreeMetadataEmitter(LoggingMixin):
2610 libs[key] = l
2611 if key not in libs:
2612 libs[key] = l
2613- candidates = libs.values()
2614+ candidates = list(libs.values())
2615 if force_static and not candidates:
2616 if dir:
2617 raise SandboxValidationError(
2618@@ -473,9 +473,9 @@ class TreeMetadataEmitter(LoggingMixin):
2619
2620 def _verify_deps(self, context, crate_dir, crate_name, dependencies, description='Dependency'):
2621 """Verify that a crate's dependencies all specify local paths."""
2622- for dep_crate_name, values in dependencies.iteritems():
2623+ for dep_crate_name, values in dependencies.items():
2624 # A simple version number.
2625- if isinstance(values, (str, unicode)):
2626+ if isinstance(values, str):
2627 raise SandboxValidationError(
2628 '%s %s of crate %s does not list a path' % (description, dep_crate_name, crate_name),
2629 context)
2630@@ -529,7 +529,7 @@ class TreeMetadataEmitter(LoggingMixin):
2631
2632 cargo_target_dir = context.get('RUST_LIBRARY_TARGET_DIR', '.')
2633
2634- dependencies = set(config.get('dependencies', {}).iterkeys())
2635+ dependencies = set(config.get('dependencies', {}).keys())
2636
2637 features = context.get(cls.FEATURES_VAR, [])
2638 unique_features = set(features)
2639@@ -863,7 +863,7 @@ class TreeMetadataEmitter(LoggingMixin):
2640 assert not gen_sources['UNIFIED_SOURCES']
2641
2642 no_pgo = context.get('NO_PGO')
2643- no_pgo_sources = [f for f, flags in all_flags.iteritems()
2644+ no_pgo_sources = [f for f, flags in all_flags.items()
2645 if flags.no_pgo]
2646 if no_pgo:
2647 if no_pgo_sources:
2648@@ -890,7 +890,7 @@ class TreeMetadataEmitter(LoggingMixin):
2649
2650 # The inverse of the above, mapping suffixes to their canonical suffix.
2651 canonicalized_suffix_map = {}
2652- for suffix, alternatives in suffix_map.iteritems():
2653+ for suffix, alternatives in suffix_map.items():
2654 alternatives.add(suffix)
2655 for a in alternatives:
2656 canonicalized_suffix_map[a] = suffix
2657@@ -914,7 +914,7 @@ class TreeMetadataEmitter(LoggingMixin):
2658 # Source files to track for linkables associated with this context.
2659 ctxt_sources = defaultdict(lambda: defaultdict(list))
2660
2661- for variable, (klass, gen_klass, suffixes) in varmap.items():
2662+ for variable, (klass, gen_klass, suffixes) in list(varmap.items()):
2663 allowed_suffixes = set().union(*[suffix_map[s] for s in suffixes])
2664
2665 # First ensure that we haven't been given filetypes that we don't
2666@@ -941,20 +941,20 @@ class TreeMetadataEmitter(LoggingMixin):
2667 obj = cls(*arglist)
2668 srcs = obj.files
2669 if isinstance(obj, UnifiedSources) and obj.have_unified_mapping:
2670- srcs = dict(obj.unified_source_mapping).keys()
2671+ srcs = list(dict(obj.unified_source_mapping).keys())
2672 ctxt_sources[variable][canonical_suffix] += sorted(srcs)
2673 yield obj
2674
2675 if ctxt_sources:
2676 for linkable in linkables:
2677 for target_var in ('SOURCES', 'UNIFIED_SOURCES'):
2678- for suffix, srcs in ctxt_sources[target_var].items():
2679+ for suffix, srcs in list(ctxt_sources[target_var].items()):
2680 linkable.sources[suffix] += srcs
2681 for host_linkable in host_linkables:
2682- for suffix, srcs in ctxt_sources['HOST_SOURCES'].items():
2683+ for suffix, srcs in list(ctxt_sources['HOST_SOURCES'].items()):
2684 host_linkable.sources[suffix] += srcs
2685
2686- for f, flags in all_flags.iteritems():
2687+ for f, flags in all_flags.items():
2688 if flags.flags:
2689 ext = mozpath.splitext(f)[1]
2690 yield PerSourceFlag(context, f, flags.flags)
2691@@ -1143,7 +1143,7 @@ class TreeMetadataEmitter(LoggingMixin):
2692 for obj in self._handle_linkables(context, passthru, generated_files):
2693 yield obj
2694
2695- generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in self._binaries.keys()])
2696+ generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in list(self._binaries.keys())])
2697
2698 components = []
2699 for var, cls in (
2700@@ -1277,7 +1277,7 @@ class TreeMetadataEmitter(LoggingMixin):
2701 for obj in self._process_jar_manifests(context):
2702 yield obj
2703
2704- for name, jar in context.get('JAVA_JAR_TARGETS', {}).items():
2705+ for name, jar in list(context.get('JAVA_JAR_TARGETS', {}).items()):
2706 yield ContextWrapped(context, jar)
2707
2708 computed_as_flags.resolve_flags('MOZBUILD',
2709@@ -1346,7 +1346,7 @@ class TreeMetadataEmitter(LoggingMixin):
2710 script = mozpath.join(mozpath.dirname(mozpath.dirname(__file__)),
2711 'action', 'process_define_files.py')
2712 yield GeneratedFile(context, script, 'process_define_file',
2713- unicode(path),
2714+ str(path),
2715 [Path(context, path + '.in')])
2716
2717 generated_files = context.get('GENERATED_FILES') or []
2718@@ -1393,7 +1393,7 @@ class TreeMetadataEmitter(LoggingMixin):
2719 flags.flags, localized=localized)
2720
2721 def _process_test_manifests(self, context):
2722- for prefix, info in TEST_MANIFESTS.items():
2723+ for prefix, info in list(TEST_MANIFESTS.items()):
2724 for path, manifest in context.get('%s_MANIFESTS' % prefix, []):
2725 for obj in self._process_test_manifest(context, info, path, manifest):
2726 yield obj
2727@@ -1479,7 +1479,7 @@ class TreeMetadataEmitter(LoggingMixin):
2728
2729 process_support_files(test)
2730
2731- for path, m_defaults in mpmanifest.manifest_defaults.items():
2732+ for path, m_defaults in list(mpmanifest.manifest_defaults.items()):
2733 process_support_files(m_defaults)
2734
2735 # We also copy manifests into the output directory,
2736diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py
2737index c1efc1c3d..0cdf8b8db 100644
2738--- a/python/mozbuild/mozbuild/frontend/reader.py
2739+++ b/python/mozbuild/mozbuild/frontend/reader.py
2740@@ -16,7 +16,7 @@ The BuildReader contains basic logic for traversing a tree of mozbuild files.
2741 It does this by examining specific variables populated during execution.
2742 """
2743
2744-from __future__ import absolute_import, print_function, unicode_literals
2745+
2746
2747 import ast
2748 import inspect
2749@@ -81,12 +81,13 @@ from .context import (
2750
2751 from mozbuild.base import ExecutionSummary
2752 from concurrent.futures.process import ProcessPoolExecutor
2753+from functools import reduce
2754
2755
2756
2757 if sys.version_info.major == 2:
2758- text_type = unicode
2759- type_type = types.TypeType
2760+ text_type = str
2761+ type_type = type
2762 else:
2763 text_type = str
2764 type_type = type
2765@@ -127,7 +128,7 @@ class EmptyConfig(object):
2766
2767 self.substs = self.PopulateOnGetDict(EmptyValue, substs or self.default_substs)
2768 udict = {}
2769- for k, v in self.substs.items():
2770+ for k, v in list(self.substs.items()):
2771 if isinstance(v, str):
2772 udict[k.decode('utf-8')] = v.decode('utf-8')
2773 else:
2774@@ -311,7 +312,7 @@ class MozbuildSandbox(Sandbox):
2775 raise Exception('`template` is a function decorator. You must '
2776 'use it as `@template` preceding a function declaration.')
2777
2778- name = func.func_name
2779+ name = func.__name__
2780
2781 if name in self.templates:
2782 raise KeyError(
2783@@ -390,7 +391,7 @@ class MozbuildSandbox(Sandbox):
2784 klass = self._context.__class__
2785 self._context.__class__ = TemplateContext
2786 # The sandbox will do all the necessary checks for these merges.
2787- for key, value in context.items():
2788+ for key, value in list(context.items()):
2789 if isinstance(value, dict):
2790 self[key].update(value)
2791 elif isinstance(value, (list, HierarchicalStringList)):
2792@@ -407,12 +408,14 @@ class MozbuildSandbox(Sandbox):
2793
2794 class TemplateFunction(object):
2795 def __init__(self, func, sandbox):
2796- self.path = func.func_code.co_filename
2797- self.name = func.func_name
2798+ self.path = func.__code__.co_filename
2799+ self.name = func.__name__
2800
2801- code = func.func_code
2802+ code = func.__code__
2803 firstlineno = code.co_firstlineno
2804 lines = sandbox._current_source.splitlines(True)
2805+ if len(lines) and isinstance(lines[0], bytes):
2806+ lines = [l.decode('utf-8') for l in lines]
2807 lines = inspect.getblock(lines[firstlineno - 1:])
2808
2809 # The code lines we get out of inspect.getsourcelines look like
2810@@ -430,7 +433,7 @@ class TemplateFunction(object):
2811 # actually never calls __getitem__ and __setitem__, so we need to
2812 # modify the AST so that accesses to globals are properly directed
2813 # to a dict.
2814- self._global_name = b'_data' # AST wants str for this, not unicode
2815+ self._global_name = '_data'
2816 # In case '_data' is a name used for a variable in the function code,
2817 # prepend more underscores until we find an unused name.
2818 while (self._global_name in code.co_names or
2819@@ -449,8 +452,8 @@ class TemplateFunction(object):
2820 compile(func_ast, self.path, 'exec'),
2821 glob,
2822 self.name,
2823- func.func_defaults,
2824- func.func_closure,
2825+ func.__defaults__,
2826+ func.__closure__,
2827 )
2828 func()
2829
2830@@ -464,11 +467,11 @@ class TemplateFunction(object):
2831 '__builtins__': sandbox._builtins
2832 }
2833 func = types.FunctionType(
2834- self._func.func_code,
2835+ self._func.__code__,
2836 glob,
2837 self.name,
2838- self._func.func_defaults,
2839- self._func.func_closure
2840+ self._func.__defaults__,
2841+ self._func.__closure__
2842 )
2843 sandbox.exec_function(func, args, kwargs, self.path,
2844 becomes_current_path=False)
2845@@ -484,7 +487,7 @@ class TemplateFunction(object):
2846 def visit_Str(self, node):
2847 # String nodes we got from the AST parser are str, but we want
2848 # unicode literals everywhere, so transform them.
2849- node.s = unicode(node.s)
2850+ node.s = str(node.s)
2851 return node
2852
2853 def visit_Name(self, node):
2854@@ -617,7 +620,7 @@ class BuildReaderError(Exception):
2855
2856 for l in traceback.format_exception(type(self.other), self.other,
2857 self.trace):
2858- s.write(unicode(l))
2859+ s.write(str(l))
2860
2861 return s.getvalue()
2862
2863@@ -767,7 +770,7 @@ class BuildReaderError(Exception):
2864 s.write(' %s\n' % inner.args[2])
2865 s.write('\n')
2866 close_matches = difflib.get_close_matches(inner.args[2],
2867- VARIABLES.keys(), 2)
2868+ list(VARIABLES.keys()), 2)
2869 if close_matches:
2870 s.write('Maybe you meant %s?\n' % ' or '.join(close_matches))
2871 s.write('\n')
2872@@ -1152,7 +1155,7 @@ class BuildReader(object):
2873 context)
2874 non_unified_sources.add(source)
2875 action_overrides = {}
2876- for action, script in gyp_dir.action_overrides.iteritems():
2877+ for action, script in gyp_dir.action_overrides.items():
2878 action_overrides[action] = SourcePath(context, script)
2879
2880 gyp_processor = GypProcessor(context.config,
2881@@ -1188,7 +1191,7 @@ class BuildReader(object):
2882
2883 recurse_info[d][key] = dict(sandbox.metadata[key])
2884
2885- for path, child_metadata in recurse_info.items():
2886+ for path, child_metadata in list(recurse_info.items()):
2887 child_path = path.join('moz.build').full_path
2888
2889 # Ensure we don't break out of the topsrcdir. We don't do realpath
2890@@ -1279,7 +1282,7 @@ class BuildReader(object):
2891 # There is room to improve this code (and the code in
2892 # _find_relevant_mozbuilds) to better handle multiple files in the same
2893 # directory. Bug 1136966 tracks.
2894- for path, mbpaths in relevants.items():
2895+ for path, mbpaths in list(relevants.items()):
2896 path_mozbuilds[path] = [mozpath.join(topsrcdir, p) for p in mbpaths]
2897
2898 for i, mbpath in enumerate(mbpaths[0:-1]):
2899@@ -1316,7 +1319,7 @@ class BuildReader(object):
2900 all_contexts.append(context)
2901
2902 result = {}
2903- for path, paths in path_mozbuilds.items():
2904+ for path, paths in list(path_mozbuilds.items()):
2905 result[path] = reduce(lambda x, y: x + y, (contexts[p] for p in paths), [])
2906
2907 return result, all_contexts
2908@@ -1356,7 +1359,7 @@ class BuildReader(object):
2909
2910 r = {}
2911
2912- for path, ctxs in paths.items():
2913+ for path, ctxs in list(paths.items()):
2914 # Should be normalized by read_relevant_mozbuilds.
2915 assert '\\' not in path
2916
2917diff --git a/python/mozbuild/mozbuild/frontend/sandbox.py b/python/mozbuild/mozbuild/frontend/sandbox.py
2918index b2090802e..6d94291ea 100644
2919--- a/python/mozbuild/mozbuild/frontend/sandbox.py
2920+++ b/python/mozbuild/mozbuild/frontend/sandbox.py
2921@@ -17,7 +17,7 @@ KeyError are machine parseable. This machine-friendly data is used to present
2922 user-friendly error messages in the case of errors.
2923 """
2924
2925-from __future__ import absolute_import, unicode_literals
2926+
2927
2928 import os
2929 import sys
2930@@ -112,6 +112,7 @@ class Sandbox(dict):
2931 'int': int,
2932 'set': set,
2933 'tuple': tuple,
2934+ 'str': str,
2935 })
2936
2937 def __init__(self, context, finder=default_finder):
2938diff --git a/python/mozbuild/mozbuild/jar.py b/python/mozbuild/mozbuild/jar.py
2939index 47a2eff63..96aea63ce 100644
2940--- a/python/mozbuild/mozbuild/jar.py
2941+++ b/python/mozbuild/mozbuild/jar.py
2942@@ -8,7 +8,7 @@ processing jar.mn files.
2943 See the documentation for jar.mn on MDC for further details on the format.
2944 '''
2945
2946-from __future__ import absolute_import
2947+
2948
2949 import sys
2950 import os
2951@@ -17,7 +17,7 @@ import re
2952 import logging
2953 from time import localtime
2954 from MozZipFile import ZipFile
2955-from cStringIO import StringIO
2956+from io import StringIO
2957 from collections import defaultdict
2958
2959 from mozbuild.preprocessor import Preprocessor
2960@@ -302,9 +302,9 @@ class JarMaker(object):
2961 '''updateManifest replaces the % in the chrome registration entries
2962 with the given chrome base path, and updates the given manifest file.
2963 '''
2964- myregister = dict.fromkeys(map(lambda s: s.replace('%',
2965- chromebasepath), register))
2966- addEntriesToListFile(manifestPath, myregister.iterkeys())
2967+ myregister = dict.fromkeys([s.replace('%',
2968+ chromebasepath) for s in register])
2969+ addEntriesToListFile(manifestPath, iter(myregister.keys()))
2970
2971 def makeJar(self, infile, jardir):
2972 '''makeJar is the main entry point to JarMaker.
2973@@ -322,7 +322,7 @@ class JarMaker(object):
2974 elif self.relativesrcdir:
2975 self.localedirs = \
2976 self.generateLocaleDirs(self.relativesrcdir)
2977- if isinstance(infile, basestring):
2978+ if isinstance(infile, str):
2979 logging.info('processing ' + infile)
2980 self.sourcedirs.append(_normpath(os.path.dirname(infile)))
2981 pp = self.pp.clone()
2982diff --git a/python/mozbuild/mozbuild/makeutil.py b/python/mozbuild/mozbuild/makeutil.py
2983index fcd45bed2..f77c5d2c3 100644
2984--- a/python/mozbuild/mozbuild/makeutil.py
2985+++ b/python/mozbuild/mozbuild/makeutil.py
2986@@ -2,11 +2,10 @@
2987 # License, v. 2.0. If a copy of the MPL was not distributed with this
2988 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
2989
2990-from __future__ import absolute_import
2991+
2992
2993 import os
2994 import re
2995-from types import StringTypes
2996 from collections import Iterable
2997
2998
2999@@ -66,7 +65,7 @@ class _SimpleOrderedSet(object):
3000 self._list = []
3001 self._set = set()
3002
3003- def __nonzero__(self):
3004+ def __bool__(self):
3005 return bool(self._set)
3006
3007 def __iter__(self):
3008@@ -103,19 +102,19 @@ class Rule(object):
3009
3010 def add_targets(self, targets):
3011 '''Add additional targets to the rule.'''
3012- assert isinstance(targets, Iterable) and not isinstance(targets, StringTypes)
3013+ assert isinstance(targets, Iterable) and not isinstance(targets, str)
3014 self._targets.update(targets)
3015 return self
3016
3017 def add_dependencies(self, deps):
3018 '''Add dependencies to the rule.'''
3019- assert isinstance(deps, Iterable) and not isinstance(deps, StringTypes)
3020+ assert isinstance(deps, Iterable) and not isinstance(deps, str)
3021 self._dependencies.update(deps)
3022 return self
3023
3024 def add_commands(self, commands):
3025 '''Add commands to the rule.'''
3026- assert isinstance(commands, Iterable) and not isinstance(commands, StringTypes)
3027+ assert isinstance(commands, Iterable) and not isinstance(commands, str)
3028 self._commands.extend(commands)
3029 return self
3030
3031@@ -139,13 +138,16 @@ class Rule(object):
3032 '''
3033 if not self._targets:
3034 return
3035- fh.write('%s:' % ' '.join(self._targets))
3036+ wstring = '%s:' % ' '.join(self._targets)
3037 if self._dependencies:
3038- fh.write(' %s' % ' '.join(self.dependencies()))
3039- fh.write('\n')
3040+ wstring += ' %s' % ' '.join(self.dependencies())
3041+ wstring += '\n'
3042 for cmd in self._commands:
3043- fh.write('\t%s\n' % cmd)
3044-
3045+ wstring += '\t%s\n' % cmd
3046+ try:
3047+ fh.write(wstring.encode('utf-8'))
3048+ except TypeError:
3049+ fh.write(wstring)
3050
3051 # colon followed by anything except a slash (Windows path detection)
3052 _depfilesplitter = re.compile(r':(?![\\/])')
3053diff --git a/python/mozbuild/mozbuild/mozinfo.py b/python/mozbuild/mozbuild/mozinfo.py
3054index 7e7ad1b2a..f03f20ba3 100755
3055--- a/python/mozbuild/mozbuild/mozinfo.py
3056+++ b/python/mozbuild/mozbuild/mozinfo.py
3057@@ -5,7 +5,7 @@
3058 # This module produces a JSON file that provides basic build info and
3059 # configuration metadata.
3060
3061-from __future__ import absolute_import
3062+
3063
3064 import os
3065 import re
3066@@ -33,7 +33,7 @@ def build_dict(config, env=os.environ):
3067 d['mozconfig'] = config.mozconfig
3068
3069 # os
3070- o = substs["OS_TARGET"]
3071+ o = str(substs["OS_TARGET"])
3072 known_os = {"Linux": "linux",
3073 "WINNT": "win",
3074 "Darwin": "mac",
3075@@ -148,7 +148,7 @@ def write_mozinfo(file, config, env=os.environ):
3076 and what keys are produced.
3077 """
3078 build_conf = build_dict(config, env)
3079- if isinstance(file, basestring):
3080- file = open(file, 'wb')
3081+ if isinstance(file, str):
3082+ file = open(file, 'w')
3083
3084 json.dump(build_conf, file, sort_keys=True, indent=4)
3085diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
3086index 6780b8b72..19e59884e 100644
3087--- a/python/mozbuild/mozbuild/preprocessor.py
3088+++ b/python/mozbuild/mozbuild/preprocessor.py
3089@@ -27,7 +27,8 @@ import os
3090 import re
3091 from optparse import OptionParser
3092 import errno
3093-from makeutil import Makefile
3094+from .makeutil import Makefile
3095+from functools import reduce
3096
3097 # hack around win32 mangling our line endings
3098 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443
3099@@ -230,7 +231,7 @@ class Expression:
3100 def __repr__(self):
3101 return self.value.__repr__()
3102
3103- class ParseError(StandardError):
3104+ class ParseError(Exception):
3105 """
3106 Error raised when parsing fails.
3107 It has two members, offset and content, which give the offset of the
3108@@ -278,7 +279,7 @@ class Preprocessor:
3109 self.context = Context()
3110 for k,v in {'FILE': '',
3111 'LINE': 0,
3112- 'DIRECTORY': os.path.abspath('.')}.iteritems():
3113+ 'DIRECTORY': os.path.abspath('.')}.items():
3114 self.context[k] = v
3115 self.actionLevel = 0
3116 self.disableLevel = 0
3117@@ -292,21 +293,21 @@ class Preprocessor:
3118 self.cmds = {}
3119 for cmd, level in {'define': 0,
3120 'undef': 0,
3121- 'if': sys.maxint,
3122- 'ifdef': sys.maxint,
3123- 'ifndef': sys.maxint,
3124+ 'if': sys.maxsize,
3125+ 'ifdef': sys.maxsize,
3126+ 'ifndef': sys.maxsize,
3127 'else': 1,
3128 'elif': 1,
3129 'elifdef': 1,
3130 'elifndef': 1,
3131- 'endif': sys.maxint,
3132+ 'endif': sys.maxsize,
3133 'expand': 0,
3134 'literal': 0,
3135 'filter': 0,
3136 'unfilter': 0,
3137 'include': 0,
3138 'includesubst': 0,
3139- 'error': 0}.iteritems():
3140+ 'error': 0}.items():
3141 self.cmds[cmd] = (level, getattr(self, 'do_' + cmd))
3142 self.out = sys.stdout
3143 self.setMarker(marker)
3144@@ -434,7 +435,7 @@ class Preprocessor:
3145 filteredLine = self.applyFilters(aLine)
3146 if filteredLine != aLine:
3147 self.actionLevel = 2
3148- self.out.write(filteredLine)
3149+ self.out.write(filteredLine.encode('utf-8'))
3150
3151 def handleCommandLine(self, args, defaultToStdin = False):
3152 """
3153@@ -468,7 +469,7 @@ class Preprocessor:
3154 raise Preprocessor.Error(self, "--depend doesn't work with stdout",
3155 None)
3156 try:
3157- from makeutil import Makefile
3158+ from .makeutil import Makefile
3159 except:
3160 raise Preprocessor.Error(self, "--depend requires the "
3161 "mozbuild.makeutil module", None)
3162@@ -683,7 +684,7 @@ class Preprocessor:
3163 current = dict(self.filters)
3164 for f in filters:
3165 current[f] = getattr(self, 'filter_' + f)
3166- filterNames = current.keys()
3167+ filterNames = list(current.keys())
3168 filterNames.sort()
3169 self.filters = [(fn, current[fn]) for fn in filterNames]
3170 return
3171@@ -693,7 +694,7 @@ class Preprocessor:
3172 for f in filters:
3173 if f in current:
3174 del current[f]
3175- filterNames = current.keys()
3176+ filterNames = list(current.keys())
3177 filterNames.sort()
3178 self.filters = [(fn, current[fn]) for fn in filterNames]
3179 return
3180@@ -738,7 +739,7 @@ class Preprocessor:
3181 args can either be a file name, or a file-like object.
3182 Files should be opened, and will be closed after processing.
3183 """
3184- isName = type(args) == str or type(args) == unicode
3185+ isName = type(args) == str or type(args) == str
3186 oldCheckLineNumbers = self.checkLineNumbers
3187 self.checkLineNumbers = False
3188 if isName:
3189diff --git a/python/mozbuild/mozbuild/shellutil.py b/python/mozbuild/mozbuild/shellutil.py
3190index 185a970ee..c0c15f8f2 100644
3191--- a/python/mozbuild/mozbuild/shellutil.py
3192+++ b/python/mozbuild/mozbuild/shellutil.py
3193@@ -15,7 +15,7 @@ def _tokens2re(**tokens):
3194 # which matches the pattern and captures it in a named match group.
3195 # The group names and patterns are given as arguments.
3196 all_tokens = '|'.join('(?P<%s>%s)' % (name, value)
3197- for name, value in tokens.iteritems())
3198+ for name, value in tokens.items())
3199 nonescaped = r'(?<!\\)(?:%s)' % all_tokens
3200
3201 # The final pattern matches either the above pattern, or an escaped
3202@@ -96,7 +96,7 @@ class _ClineSplitter(object):
3203 self.cline = self.cline[m.end():]
3204
3205 match = {name: value
3206- for name, value in m.groupdict().items() if value}
3207+ for name, value in list(m.groupdict().items()) if value}
3208 if 'quote' in match:
3209 # " or ' start a quoted string
3210 if match['quote'] == '"':
3211@@ -144,7 +144,7 @@ class _ClineSplitter(object):
3212 self._push(self.cline[:m.start()])
3213 self.cline = self.cline[m.end():]
3214 match = {name: value
3215- for name, value in m.groupdict().items() if value}
3216+ for name, value in list(m.groupdict().items()) if value}
3217 if 'quote' in match:
3218 # a double quote ends the quoted string, so go back to
3219 # unquoted parsing
3220diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
3221index a05059f8a..355a96165 100644
3222--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
3223+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
3224@@ -2,9 +2,9 @@
3225 # License, v. 2.0. If a copy of the MPL was not distributed with this
3226 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3227
3228-from __future__ import unicode_literals
3229
3230-import cPickle as pickle
3231+
3232+import pickle as pickle
3233 import json
3234 import os
3235 import unittest
3236@@ -333,7 +333,7 @@ class TestRecursiveMakeBackend(BackendTester):
3237 ],
3238 }
3239
3240- for var, val in expected.items():
3241+ for var, val in list(expected.items()):
3242 # print("test_variable_passthru[%s]" % (var))
3243 found = [str for str in lines if str.startswith(var)]
3244 self.assertEqual(found, val)
3245@@ -372,7 +372,7 @@ class TestRecursiveMakeBackend(BackendTester):
3246 ],
3247 }
3248
3249- for var, val in expected.items():
3250+ for var, val in list(expected.items()):
3251 found = [str for str in lines if str.startswith(var)]
3252 self.assertEqual(found, val)
3253
3254@@ -563,7 +563,7 @@ class TestRecursiveMakeBackend(BackendTester):
3255
3256 # This is not the most robust test in the world, but it gets the job
3257 # done.
3258- entries = [e for e in m._dests.keys() if '**' in e]
3259+ entries = [e for e in list(m._dests.keys()) if '**' in e]
3260 self.assertEqual(len(entries), 1)
3261 self.assertIn('support/**', entries[0])
3262
3263@@ -590,11 +590,11 @@ class TestRecursiveMakeBackend(BackendTester):
3264 set(['child/test_sub.js',
3265 'child/data/**',
3266 'child/another-file.sjs']))
3267- for key in test_installs.keys():
3268+ for key in list(test_installs.keys()):
3269 self.assertIn(key, test_installs)
3270
3271 synthesized_manifest = InstallManifest()
3272- for item, installs in test_installs.items():
3273+ for item, installs in list(test_installs.items()):
3274 for install_info in installs:
3275 if len(install_info) == 3:
3276 synthesized_manifest.add_pattern_link(*install_info)
3277@@ -602,7 +602,7 @@ class TestRecursiveMakeBackend(BackendTester):
3278 synthesized_manifest.add_link(*install_info)
3279
3280 self.assertEqual(len(synthesized_manifest), 3)
3281- for item, info in synthesized_manifest._dests.items():
3282+ for item, info in list(synthesized_manifest._dests.items()):
3283 self.assertIn(item, m)
3284 self.assertEqual(info, m._dests[item])
3285
3286@@ -864,7 +864,7 @@ class TestRecursiveMakeBackend(BackendTester):
3287 expected[mozpath.join(env.topobjdir, 'final-target')] = [
3288 'FINAL_TARGET = $(DEPTH)/random-final-target'
3289 ]
3290- for key, expected_rules in expected.iteritems():
3291+ for key, expected_rules in expected.items():
3292 backend_path = mozpath.join(key, 'backend.mk')
3293 lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
3294 found = [str for str in lines if
3295diff --git a/python/mozbuild/mozbuild/test/configure/common.py b/python/mozbuild/mozbuild/test/configure/common.py
3296index 150c6e393..5e2c2afaa 100644
3297--- a/python/mozbuild/mozbuild/test/configure/common.py
3298+++ b/python/mozbuild/mozbuild/test/configure/common.py
3299@@ -2,7 +2,7 @@
3300 # License, v. 2.0. If a copy of the MPL was not distributed with this
3301 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3302
3303-from __future__ import absolute_import, print_function, unicode_literals
3304+
3305
3306 import copy
3307 import errno
3308@@ -16,7 +16,7 @@ from mozbuild.configure import ConfigureSandbox
3309 from mozbuild.util import ReadOnlyNamespace
3310 from mozpack import path as mozpath
3311
3312-from StringIO import StringIO
3313+from io import StringIO
3314 from which import WhichError
3315
3316 from buildconfig import (
3317@@ -77,10 +77,10 @@ class ConfigureTestSandbox(ConfigureSandbox):
3318 self._search_path = environ.get('PATH', '').split(os.pathsep)
3319
3320 self._subprocess_paths = {
3321- mozpath.abspath(k): v for k, v in paths.iteritems() if v
3322+ mozpath.abspath(k): v for k, v in paths.items() if v
3323 }
3324
3325- paths = paths.keys()
3326+ paths = list(paths.keys())
3327
3328 environ = dict(environ)
3329 if 'CONFIG_SHELL' not in environ:
3330diff --git a/python/mozbuild/mozbuild/test/configure/lint.py b/python/mozbuild/mozbuild/test/configure/lint.py
3331index 98f5f4fe7..a549b4bcf 100644
3332--- a/python/mozbuild/mozbuild/test/configure/lint.py
3333+++ b/python/mozbuild/mozbuild/test/configure/lint.py
3334@@ -2,11 +2,11 @@
3335 # License, v. 2.0. If a copy of the MPL was not distributed with this
3336 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3337
3338-from __future__ import absolute_import, print_function, unicode_literals
3339+
3340
3341 import os
3342 import unittest
3343-from StringIO import StringIO
3344+from io import StringIO
3345 from mozunit import main
3346 from buildconfig import (
3347 topobjdir,
3348@@ -40,9 +40,7 @@ class LintMeta(type):
3349 return type.__new__(mcs, name, bases, attrs)
3350
3351
3352-class Lint(unittest.TestCase):
3353- __metaclass__ = LintMeta
3354-
3355+class Lint(unittest.TestCase, metaclass=LintMeta):
3356 def setUp(self):
3357 self._curdir = os.getcwd()
3358 os.chdir(topobjdir)
3359diff --git a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py
3360index c60000bb2..07091c077 100644
3361--- a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py
3362+++ b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py
3363@@ -2,9 +2,9 @@
3364 # License, v. 2.0. If a copy of the MPL was not distributed with this
3365 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3366
3367-from __future__ import absolute_import, print_function, unicode_literals
3368
3369-from StringIO import StringIO
3370+
3371+from io import StringIO
3372 import os
3373 import sys
3374 import textwrap
3375@@ -447,7 +447,7 @@ class TestChecksConfigure(unittest.TestCase):
3376 checking for a... %s
3377 ''' % self.OTHER_A))
3378
3379- dirs = map(mozpath.dirname, (self.OTHER_A, self.KNOWN_A))
3380+ dirs = list(map(mozpath.dirname, (self.OTHER_A, self.KNOWN_A)))
3381 config, out, status = self.get_result(textwrap.dedent('''\
3382 check_prog("A", ("known-a",), paths=["%s"])
3383 ''' % os.pathsep.join(dirs)))
3384@@ -457,7 +457,7 @@ class TestChecksConfigure(unittest.TestCase):
3385 checking for a... %s
3386 ''' % self.OTHER_A))
3387
3388- dirs = map(mozpath.dirname, (self.KNOWN_A, self.KNOWN_B))
3389+ dirs = list(map(mozpath.dirname, (self.KNOWN_A, self.KNOWN_B)))
3390 config, out, status = self.get_result(textwrap.dedent('''\
3391 check_prog("A", ("known-a",), paths=["%s", "%s"])
3392 ''' % (os.pathsep.join(dirs), self.OTHER_A)))
3393diff --git a/python/mozbuild/mozbuild/test/configure/test_compile_checks.py b/python/mozbuild/mozbuild/test/configure/test_compile_checks.py
3394index b5be3bf2e..282000bb2 100644
3395--- a/python/mozbuild/mozbuild/test/configure/test_compile_checks.py
3396+++ b/python/mozbuild/mozbuild/test/configure/test_compile_checks.py
3397@@ -2,14 +2,14 @@
3398 # License, v. 2.0. If a copy of the MPL was not distributed with this
3399 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3400
3401-from __future__ import absolute_import, print_function, unicode_literals
3402+
3403
3404 import os
3405 import textwrap
3406 import unittest
3407 import mozpack.path as mozpath
3408
3409-from StringIO import StringIO
3410+from io import StringIO
3411
3412 from buildconfig import topsrcdir
3413 from common import ConfigureTestSandbox
3414diff --git a/python/mozbuild/mozbuild/test/configure/test_configure.py b/python/mozbuild/mozbuild/test/configure/test_configure.py
3415index f37e2701f..eb0ca84fb 100644
3416--- a/python/mozbuild/mozbuild/test/configure/test_configure.py
3417+++ b/python/mozbuild/mozbuild/test/configure/test_configure.py
3418@@ -2,9 +2,9 @@
3419 # License, v. 2.0. If a copy of the MPL was not distributed with this
3420 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
3421
3422-from __future__ import absolute_import, print_function, unicode_literals
3423
3424-from StringIO import StringIO
3425+
3426+from io import StringIO
3427 import os
3428 import sys
3429 import textwrap
3430@@ -43,7 +43,7 @@ class TestConfigure(unittest.TestCase):
3431
3432 if '--help' in options:
3433 return out.getvalue(), config
3434- self.assertEquals('', out.getvalue())
3435+ self.assertEqual('', out.getvalue())
3436 return config
3437
3438 def moz_configure(self, source):
3439@@ -55,7 +55,7 @@ class TestConfigure(unittest.TestCase):
3440 def test_defaults(self):
3441 config = self.get_config()
3442 self.maxDiff = None
3443- self.assertEquals({
3444+ self.assertEqual({
3445 'CHOICES': NegativeOptionValue(),
3446 'DEFAULTED': PositiveOptionValue(('not-simple',)),
3447 'IS_GCC': NegativeOptionValue(),
3448@@ -71,9 +71,9 @@ class TestConfigure(unittest.TestCase):
3449 def test_help(self):
3450 help, config = self.get_config(['--help'], prog='configure')
3451
3452- self.assertEquals({}, config)
3453+ self.assertEqual({}, config)
3454 self.maxDiff = None
3455- self.assertEquals(
3456+ self.assertEqual(
3457 'Usage: configure [options]\n'
3458 '\n'
3459 'Options: [defaults in brackets after descriptions]\n'
3460@@ -109,7 +109,7 @@ class TestConfigure(unittest.TestCase):
3461 ):
3462 self.assertNotIn('ENABLED_SIMPLE', config)
3463 self.assertIn('SIMPLE', config)
3464- self.assertEquals(NegativeOptionValue(), config['SIMPLE'])
3465+ self.assertEqual(NegativeOptionValue(), config['SIMPLE'])
3466
3467 for config in (
3468 self.get_config(['--enable-simple']),
3469@@ -117,7 +117,7 @@ class TestConfigure(unittest.TestCase):
3470 ):
3471 self.assertIn('ENABLED_SIMPLE', config)
3472 self.assertIn('SIMPLE', config)
3473- self.assertEquals(PositiveOptionValue(), config['SIMPLE'])
3474+ self.assertEqual(PositiveOptionValue(), config['SIMPLE'])
3475 self.assertIs(config['SIMPLE'], config['ENABLED_SIMPLE'])
3476
3477 # --enable-simple doesn't take values.
3478@@ -135,7 +135,7 @@ class TestConfigure(unittest.TestCase):
3479 env={'MOZ_WITH_ENV': '1'}),
3480 ):
3481 self.assertIn('WITH_ENV', config)
3482- self.assertEquals(NegativeOptionValue(), config['WITH_ENV'])
3483+ self.assertEqual(NegativeOptionValue(), config['WITH_ENV'])
3484
3485 for config in (
3486 self.get_config(['--enable-with-env']),
3487@@ -145,7 +145,7 @@ class TestConfigure(unittest.TestCase):
3488 env={'MOZ_WITH_ENV': ''}),
3489 ):
3490 self.assertIn('WITH_ENV', config)
3491- self.assertEquals(PositiveOptionValue(), config['WITH_ENV'])
3492+ self.assertEqual(PositiveOptionValue(), config['WITH_ENV'])
3493
3494 with self.assertRaises(InvalidOptionError):
3495 self.get_config(['--enable-with-env=value'])
3496@@ -160,23 +160,23 @@ class TestConfigure(unittest.TestCase):
3497 self.get_config(['--enable-values', '--disable-values']),
3498 ):
3499 self.assertIn(name, config)
3500- self.assertEquals(NegativeOptionValue(), config[name])
3501+ self.assertEqual(NegativeOptionValue(), config[name])
3502
3503 for config in (
3504 self.get_config(['--enable-values']),
3505 self.get_config(['--disable-values', '--enable-values']),
3506 ):
3507 self.assertIn(name, config)
3508- self.assertEquals(PositiveOptionValue(), config[name])
3509+ self.assertEqual(PositiveOptionValue(), config[name])
3510
3511 config = self.get_config(['--enable-values=foo'])
3512 self.assertIn(name, config)
3513- self.assertEquals(PositiveOptionValue(('foo',)), config[name])
3514+ self.assertEqual(PositiveOptionValue(('foo',)), config[name])
3515
3516 config = self.get_config(['--enable-values=foo,bar'])
3517 self.assertIn(name, config)
3518 self.assertTrue(config[name])
3519- self.assertEquals(PositiveOptionValue(('foo', 'bar')), config[name])
3520+ self.assertEqual(PositiveOptionValue(('foo', 'bar')), config[name])
3521
3522 def test_values2(self):
3523 self.test_values('VALUES2')
3524@@ -187,12 +187,12 @@ class TestConfigure(unittest.TestCase):
3525 def test_returned_default(self):
3526 config = self.get_config(['--enable-simple'])
3527 self.assertIn('DEFAULTED', config)
3528- self.assertEquals(
3529+ self.assertEqual(
3530 PositiveOptionValue(('simple',)), config['DEFAULTED'])
3531
3532 config = self.get_config(['--disable-simple'])
3533 self.assertIn('DEFAULTED', config)
3534- self.assertEquals(
3535+ self.assertEqual(
3536 PositiveOptionValue(('not-simple',)), config['DEFAULTED'])
3537
3538 def test_returned_choices(self):
3539@@ -200,13 +200,13 @@ class TestConfigure(unittest.TestCase):
3540 config = self.get_config(
3541 ['--enable-values=alpha', '--returned-choices=%s' % val])
3542 self.assertIn('CHOICES', config)
3543- self.assertEquals(PositiveOptionValue((val,)), config['CHOICES'])
3544+ self.assertEqual(PositiveOptionValue((val,)), config['CHOICES'])
3545
3546 for val in ('0', '1', '2'):
3547 config = self.get_config(
3548 ['--enable-values=numeric', '--returned-choices=%s' % val])
3549 self.assertIn('CHOICES', config)
3550- self.assertEquals(PositiveOptionValue((val,)), config['CHOICES'])
3551+ self.assertEqual(PositiveOptionValue((val,)), config['CHOICES'])
3552
3553 with self.assertRaises(InvalidOptionError):
3554 self.get_config(['--enable-values=numeric',
3555@@ -218,12 +218,12 @@ class TestConfigure(unittest.TestCase):
3556 def test_included(self):
3557 config = self.get_config(env={'CC': 'gcc'})
3558 self.assertIn('IS_GCC', config)
3559- self.assertEquals(config['IS_GCC'], True)
3560+ self.assertEqual(config['IS_GCC'], True)
3561
3562 config = self.get_config(
3563 ['--enable-include=extra.configure', '--extra'])
3564 self.assertIn('EXTRA', config)
3565- self.assertEquals(PositiveOptionValue(), config['EXTRA'])
3566+ self.assertEqual(PositiveOptionValue(), config['EXTRA'])
3567
3568 with self.assertRaises(InvalidOptionError):
3569 self.get_config(['--extra'])
3570@@ -231,7 +231,7 @@ class TestConfigure(unittest.TestCase):
3571 def test_template(self):
3572 config = self.get_config(env={'CC': 'gcc'})
3573 self.assertIn('CFLAGS', config)
3574- self.assertEquals(config['CFLAGS'], ['-Werror=foobar'])
3575+ self.assertEqual(config['CFLAGS'], ['-Werror=foobar'])
3576
3577 config = self.get_config(env={'CC': 'clang'})
3578 self.assertNotIn('CFLAGS', config)
3579@@ -288,7 +288,7 @@ class TestConfigure(unittest.TestCase):
3580 sandbox
3581 )
3582
3583- import __builtin__
3584+ import builtins
3585 self.assertIs(sandbox['foo'](), __builtin__)
3586
3587 exec_(textwrap.dedent('''
3588@@ -300,7 +300,7 @@ class TestConfigure(unittest.TestCase):
3589 )
3590
3591 f = sandbox['foo']()
3592- self.assertEquals(f.name, os.devnull)
3593+ self.assertEqual(f.name, os.devnull)
3594 f.close()
3595
3596 # This unlocks the sandbox
3597@@ -336,8 +336,8 @@ class TestConfigure(unittest.TestCase):
3598 self.assertIs(sandbox['foo'](), sandbox)
3599
3600 # Nothing leaked from the function being executed
3601- self.assertEquals(sandbox.keys(), ['__builtins__', 'foo'])
3602- self.assertEquals(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
3603+ self.assertEqual(list(sandbox.keys()), ['__builtins__', 'foo'])
3604+ self.assertEqual(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
3605
3606 exec_(textwrap.dedent('''
3607 @template
3608@@ -354,7 +354,7 @@ class TestConfigure(unittest.TestCase):
3609 with self.assertRaises(NameError) as e:
3610 sandbox._depends[sandbox['bar']].result()
3611
3612- self.assertEquals(e.exception.message,
3613+ self.assertEqual(e.exception.message,
3614 "global name 'sys' is not defined")
3615
3616 def test_apply_imports(self):
3617@@ -380,28 +380,28 @@ class TestConfigure(unittest.TestCase):
3618 sandbox
3619 )
3620
3621- self.assertEquals(len(imports), 1)
3622+ self.assertEqual(len(imports), 1)
3623
3624 def test_os_path(self):
3625 config = self.get_config(['--with-imports=%s' % __file__])
3626 self.assertIn('HAS_ABSPATH', config)
3627- self.assertEquals(config['HAS_ABSPATH'], True)
3628+ self.assertEqual(config['HAS_ABSPATH'], True)
3629 self.assertIn('HAS_GETATIME', config)
3630- self.assertEquals(config['HAS_GETATIME'], True)
3631+ self.assertEqual(config['HAS_GETATIME'], True)
3632 self.assertIn('HAS_GETATIME2', config)
3633- self.assertEquals(config['HAS_GETATIME2'], False)
3634+ self.assertEqual(config['HAS_GETATIME2'], False)
3635
3636 def test_template_call(self):
3637 config = self.get_config(env={'CC': 'gcc'})
3638 self.assertIn('TEMPLATE_VALUE', config)
3639- self.assertEquals(config['TEMPLATE_VALUE'], 42)
3640+ self.assertEqual(config['TEMPLATE_VALUE'], 42)
3641 self.assertIn('TEMPLATE_VALUE_2', config)
3642- self.assertEquals(config['TEMPLATE_VALUE_2'], 21)
3643+ self.assertEqual(config['TEMPLATE_VALUE_2'], 21)
3644
3645 def test_template_imports(self):
3646 config = self.get_config(['--enable-imports-in-template'])
3647 self.assertIn('PLATFORM', config)
3648- self.assertEquals(config['PLATFORM'], sys.platform)
3649+ self.assertEqual(config['PLATFORM'], sys.platform)
3650
3651 def test_decorators(self):
3652 config = {}
3653@@ -419,27 +419,27 @@ class TestConfigure(unittest.TestCase):
3654 return self.get_config(*args, configure='set_config.configure')
3655
3656 help, config = get_config(['--help'])
3657- self.assertEquals(config, {})
3658+ self.assertEqual(config, {})
3659
3660 config = get_config(['--set-foo'])
3661 self.assertIn('FOO', config)
3662- self.assertEquals(config['FOO'], True)
3663+ self.assertEqual(config['FOO'], True)
3664
3665 config = get_config(['--set-bar'])
3666 self.assertNotIn('FOO', config)
3667 self.assertIn('BAR', config)
3668- self.assertEquals(config['BAR'], True)
3669+ self.assertEqual(config['BAR'], True)
3670
3671 config = get_config(['--set-value=qux'])
3672 self.assertIn('VALUE', config)
3673- self.assertEquals(config['VALUE'], 'qux')
3674+ self.assertEqual(config['VALUE'], 'qux')
3675
3676 config = get_config(['--set-name=hoge'])
3677 self.assertIn('hoge', config)
3678- self.assertEquals(config['hoge'], True)
3679+ self.assertEqual(config['hoge'], True)
3680
3681 config = get_config([])
3682- self.assertEquals(config, {'BAR': False})
3683+ self.assertEqual(config, {'BAR': False})
3684
3685 with self.assertRaises(ConfigureError):
3686 # Both --set-foo and --set-name=FOO are going to try to
3687@@ -454,11 +454,11 @@ class TestConfigure(unittest.TestCase):
3688 set_config('QUX', 'qux', when='--with-qux')
3689 '''):
3690 config = self.get_config()
3691- self.assertEquals(config, {
3692+ self.assertEqual(config, {
3693 'FOO': 'foo',
3694 })
3695 config = self.get_config(['--with-qux'])
3696- self.assertEquals(config, {
3697+ self.assertEqual(config, {
3698 'FOO': 'foo',
3699 'QUX': 'qux',
3700 })
3701@@ -468,27 +468,27 @@ class TestConfigure(unittest.TestCase):
3702 return self.get_config(*args, configure='set_define.configure')
3703
3704 help, config = get_config(['--help'])
3705- self.assertEquals(config, {'DEFINES': {}})
3706+ self.assertEqual(config, {'DEFINES': {}})
3707
3708 config = get_config(['--set-foo'])
3709 self.assertIn('FOO', config['DEFINES'])
3710- self.assertEquals(config['DEFINES']['FOO'], True)
3711+ self.assertEqual(config['DEFINES']['FOO'], True)
3712
3713 config = get_config(['--set-bar'])
3714 self.assertNotIn('FOO', config['DEFINES'])
3715 self.assertIn('BAR', config['DEFINES'])
3716- self.assertEquals(config['DEFINES']['BAR'], True)
3717+ self.assertEqual(config['DEFINES']['BAR'], True)
3718
3719 config = get_config(['--set-value=qux'])
3720 self.assertIn('VALUE', config['DEFINES'])
3721- self.assertEquals(config['DEFINES']['VALUE'], 'qux')
3722+ self.assertEqual(config['DEFINES']['VALUE'], 'qux')
3723
3724 config = get_config(['--set-name=hoge'])
3725 self.assertIn('hoge', config['DEFINES'])
3726- self.assertEquals(config['DEFINES']['hoge'], True)
3727+ self.assertEqual(config['DEFINES']['hoge'], True)
3728
3729 config = get_config([])
3730- self.assertEquals(config['DEFINES'], {'BAR': False})
3731+ self.assertEqual(config['DEFINES'], {'BAR': False})
3732
3733 with self.assertRaises(ConfigureError):
3734 # Both --set-foo and --set-name=FOO are going to try to
3735@@ -503,11 +503,11 @@ class TestConfigure(unittest.TestCase):
3736 set_define('QUX', 'qux', when='--with-qux')
3737 '''):
3738 config = self.get_config()
3739- self.assertEquals(config['DEFINES'], {
3740+ self.assertEqual(config['DEFINES'], {
3741 'FOO': 'foo',
3742 })
3743 config = self.get_config(['--with-qux'])
3744- self.assertEquals(config['DEFINES'], {
3745+ self.assertEqual(config['DEFINES'], {
3746 'FOO': 'foo',
3747 'QUX': 'qux',
3748 })
3749@@ -518,19 +518,19 @@ class TestConfigure(unittest.TestCase):
3750 *args, configure='imply_option/simple.configure')
3751
3752 help, config = get_config(['--help'])
3753- self.assertEquals(config, {})
3754+ self.assertEqual(config, {})
3755
3756 config = get_config([])
3757- self.assertEquals(config, {})
3758+ self.assertEqual(config, {})
3759
3760 config = get_config(['--enable-foo'])
3761 self.assertIn('BAR', config)
3762- self.assertEquals(config['BAR'], PositiveOptionValue())
3763+ self.assertEqual(config['BAR'], PositiveOptionValue())
3764
3765 with self.assertRaises(InvalidOptionError) as e:
3766 get_config(['--enable-foo', '--disable-bar'])
3767
3768- self.assertEquals(
3769+ self.assertEqual(
3770 e.exception.message,
3771 "'--enable-bar' implied by '--enable-foo' conflicts with "
3772 "'--disable-bar' from the command-line")
3773@@ -541,31 +541,31 @@ class TestConfigure(unittest.TestCase):
3774 *args, configure='imply_option/negative.configure')
3775
3776 help, config = get_config(['--help'])
3777- self.assertEquals(config, {})
3778+ self.assertEqual(config, {})
3779
3780 config = get_config([])
3781- self.assertEquals(config, {})
3782+ self.assertEqual(config, {})
3783
3784 config = get_config(['--enable-foo'])
3785 self.assertIn('BAR', config)
3786- self.assertEquals(config['BAR'], NegativeOptionValue())
3787+ self.assertEqual(config['BAR'], NegativeOptionValue())
3788
3789 with self.assertRaises(InvalidOptionError) as e:
3790 get_config(['--enable-foo', '--enable-bar'])
3791
3792- self.assertEquals(
3793+ self.assertEqual(
3794 e.exception.message,
3795 "'--disable-bar' implied by '--enable-foo' conflicts with "
3796 "'--enable-bar' from the command-line")
3797
3798 config = get_config(['--disable-hoge'])
3799 self.assertIn('BAR', config)
3800- self.assertEquals(config['BAR'], NegativeOptionValue())
3801+ self.assertEqual(config['BAR'], NegativeOptionValue())
3802
3803 with self.assertRaises(InvalidOptionError) as e:
3804 get_config(['--disable-hoge', '--enable-bar'])
3805
3806- self.assertEquals(
3807+ self.assertEqual(
3808 e.exception.message,
3809 "'--disable-bar' implied by '--disable-hoge' conflicts with "
3810 "'--enable-bar' from the command-line")
3811@@ -576,23 +576,23 @@ class TestConfigure(unittest.TestCase):
3812 *args, configure='imply_option/values.configure')
3813
3814 help, config = get_config(['--help'])
3815- self.assertEquals(config, {})
3816+ self.assertEqual(config, {})
3817
3818 config = get_config([])
3819- self.assertEquals(config, {})
3820+ self.assertEqual(config, {})
3821
3822 config = get_config(['--enable-foo=a'])
3823 self.assertIn('BAR', config)
3824- self.assertEquals(config['BAR'], PositiveOptionValue(('a',)))
3825+ self.assertEqual(config['BAR'], PositiveOptionValue(('a',)))
3826
3827 config = get_config(['--enable-foo=a,b'])
3828 self.assertIn('BAR', config)
3829- self.assertEquals(config['BAR'], PositiveOptionValue(('a','b')))
3830+ self.assertEqual(config['BAR'], PositiveOptionValue(('a','b')))
3831
3832 with self.assertRaises(InvalidOptionError) as e:
3833 get_config(['--enable-foo=a,b', '--disable-bar'])
3834
3835- self.assertEquals(
3836+ self.assertEqual(
3837 e.exception.message,
3838 "'--enable-bar=a,b' implied by '--enable-foo' conflicts with "
3839 "'--disable-bar' from the command-line")
3840@@ -603,15 +603,15 @@ class TestConfigure(unittest.TestCase):
3841 *args, configure='imply_option/infer.configure')
3842
3843 help, config = get_config(['--help'])
3844- self.assertEquals(config, {})
3845+ self.assertEqual(config, {})
3846
3847 config = get_config([])
3848- self.assertEquals(config, {})
3849+ self.assertEqual(config, {})
3850
3851 with self.assertRaises(InvalidOptionError) as e:
3852 get_config(['--enable-foo', '--disable-bar'])
3853
3854- self.assertEquals(
3855+ self.assertEqual(
3856 e.exception.message,
3857 "'--enable-bar' implied by '--enable-foo' conflicts with "
3858 "'--disable-bar' from the command-line")
3859@@ -619,7 +619,7 @@ class TestConfigure(unittest.TestCase):
3860 with self.assertRaises(ConfigureError) as e:
3861 self.get_config([], configure='imply_option/infer_ko.configure')
3862
3863- self.assertEquals(
3864+ self.assertEqual(
3865 e.exception.message,
3866 "Cannot infer what implies '--enable-bar'. Please add a `reason` "
3867 "to the `imply_option` call.")
3868@@ -630,25 +630,25 @@ class TestConfigure(unittest.TestCase):
3869 *args, configure='imply_option/imm.configure')
3870
3871 help, config = get_config(['--help'])
3872- self.assertEquals(config, {})
3873+ self.assertEqual(config, {})
3874
3875 config = get_config([])
3876- self.assertEquals(config, {})
3877+ self.assertEqual(config, {})
3878
3879 config_path = mozpath.abspath(
3880 mozpath.join(test_data_path, 'imply_option', 'imm.configure'))
3881
3882- with self.assertRaisesRegexp(InvalidOptionError,
3883+ with self.assertRaisesRegex(InvalidOptionError,
3884 "--enable-foo' implied by 'imply_option at %s:7' conflicts with "
3885 "'--disable-foo' from the command-line" % config_path):
3886 get_config(['--disable-foo'])
3887
3888- with self.assertRaisesRegexp(InvalidOptionError,
3889+ with self.assertRaisesRegex(InvalidOptionError,
3890 "--enable-bar=foo,bar' implied by 'imply_option at %s:16' conflicts"
3891 " with '--enable-bar=a,b,c' from the command-line" % config_path):
3892 get_config(['--enable-bar=a,b,c'])
3893
3894- with self.assertRaisesRegexp(InvalidOptionError,
3895+ with self.assertRaisesRegex(InvalidOptionError,
3896 "--enable-baz=BAZ' implied by 'imply_option at %s:25' conflicts"
3897 " with '--enable-baz=QUUX' from the command-line" % config_path):
3898 get_config(['--enable-baz=QUUX'])
3899@@ -660,7 +660,7 @@ class TestConfigure(unittest.TestCase):
3900 '''):
3901 self.get_config()
3902
3903- self.assertEquals(e.exception.message,
3904+ self.assertEqual(e.exception.message,
3905 "`--with-foo`, emitted from `%s` line 2, is unknown."
3906 % mozpath.join(test_data_path, 'moz.configure'))
3907
3908@@ -675,7 +675,7 @@ class TestConfigure(unittest.TestCase):
3909 '''):
3910 self.get_config()
3911
3912- self.assertEquals(e.exception.message,
3913+ self.assertEqual(e.exception.message,
3914 "Unexpected type: 'int'")
3915
3916 def test_imply_option_when(self):
3917@@ -686,12 +686,12 @@ class TestConfigure(unittest.TestCase):
3918 set_config('QUX', depends('--with-qux')(lambda x: x))
3919 '''):
3920 config = self.get_config()
3921- self.assertEquals(config, {
3922+ self.assertEqual(config, {
3923 'QUX': NegativeOptionValue(),
3924 })
3925
3926 config = self.get_config(['--with-foo'])
3927- self.assertEquals(config, {
3928+ self.assertEqual(config, {
3929 'QUX': PositiveOptionValue(),
3930 })
3931
3932@@ -700,7 +700,7 @@ class TestConfigure(unittest.TestCase):
3933 with self.moz_configure('option("--with-foo", help="foo")'):
3934 self.get_config()
3935
3936- self.assertEquals(
3937+ self.assertEqual(
3938 e.exception.message,
3939 'Option `--with-foo` is not handled ; reference it with a @depends'
3940 )
3941@@ -712,7 +712,7 @@ class TestConfigure(unittest.TestCase):
3942 '''):
3943 self.get_config()
3944
3945- self.assertEquals(
3946+ self.assertEqual(
3947 e.exception.message,
3948 'Option `--with-foo` already defined'
3949 )
3950@@ -724,7 +724,7 @@ class TestConfigure(unittest.TestCase):
3951 '''):
3952 self.get_config()
3953
3954- self.assertEquals(
3955+ self.assertEqual(
3956 e.exception.message,
3957 'Option `MOZ_FOO` already defined'
3958 )
3959@@ -736,7 +736,7 @@ class TestConfigure(unittest.TestCase):
3960 '''):
3961 self.get_config()
3962
3963- self.assertEquals(
3964+ self.assertEqual(
3965 e.exception.message,
3966 'Option `MOZ_FOO` already defined'
3967 )
3968@@ -748,7 +748,7 @@ class TestConfigure(unittest.TestCase):
3969 '''):
3970 self.get_config()
3971
3972- self.assertEquals(
3973+ self.assertEqual(
3974 e.exception.message,
3975 'Option `MOZ_FOO` already defined'
3976 )
3977@@ -760,7 +760,7 @@ class TestConfigure(unittest.TestCase):
3978 '''):
3979 self.get_config()
3980
3981- self.assertEquals(
3982+ self.assertEqual(
3983 e.exception.message,
3984 'Option `--with-foo` already defined'
3985 )
3986@@ -776,18 +776,18 @@ class TestConfigure(unittest.TestCase):
3987 set_config('QUX', depends('--with-qux', when='--with-foo')(lambda x: x))
3988 '''):
3989 config = self.get_config()
3990- self.assertEquals(config, {
3991+ self.assertEqual(config, {
3992 'FOO': NegativeOptionValue(),
3993 })
3994
3995 config = self.get_config(['--with-foo'])
3996- self.assertEquals(config, {
3997+ self.assertEqual(config, {
3998 'FOO': PositiveOptionValue(),
3999 'QUX': NegativeOptionValue(),
4000 })
4001
4002 config = self.get_config(['--with-foo', '--with-qux'])
4003- self.assertEquals(config, {
4004+ self.assertEqual(config, {
4005 'FOO': PositiveOptionValue(),
4006 'QUX': PositiveOptionValue(),
4007 })
4008@@ -795,7 +795,7 @@ class TestConfigure(unittest.TestCase):
4009 with self.assertRaises(InvalidOptionError) as e:
4010 self.get_config(['--with-bar'])
4011
4012- self.assertEquals(
4013+ self.assertEqual(
4014 e.exception.message,
4015 '--with-bar is not available in this configuration'
4016 )
4017@@ -803,7 +803,7 @@ class TestConfigure(unittest.TestCase):
4018 with self.assertRaises(InvalidOptionError) as e:
4019 self.get_config(['--with-qux'])
4020
4021- self.assertEquals(
4022+ self.assertEqual(
4023 e.exception.message,
4024 '--with-qux is not available in this configuration'
4025 )
4026@@ -811,18 +811,18 @@ class TestConfigure(unittest.TestCase):
4027 with self.assertRaises(InvalidOptionError) as e:
4028 self.get_config(['QUX=1'])
4029
4030- self.assertEquals(
4031+ self.assertEqual(
4032 e.exception.message,
4033 'QUX is not available in this configuration'
4034 )
4035
4036 config = self.get_config(env={'QUX': '1'})
4037- self.assertEquals(config, {
4038+ self.assertEqual(config, {
4039 'FOO': NegativeOptionValue(),
4040 })
4041
4042 help, config = self.get_config(['--help'])
4043- self.assertEquals(help, textwrap.dedent('''\
4044+ self.assertEqual(help, textwrap.dedent('''\
4045 Usage: configure [options]
4046
4047 Options: [defaults in brackets after descriptions]
4048@@ -833,7 +833,7 @@ class TestConfigure(unittest.TestCase):
4049 '''))
4050
4051 help, config = self.get_config(['--help', '--with-foo'])
4052- self.assertEquals(help, textwrap.dedent('''\
4053+ self.assertEqual(help, textwrap.dedent('''\
4054 Usage: configure [options]
4055
4056 Options: [defaults in brackets after descriptions]
4057@@ -851,7 +851,7 @@ class TestConfigure(unittest.TestCase):
4058 with self.assertRaises(ConfigureError) as e:
4059 self.get_config()
4060
4061- self.assertEquals(e.exception.message,
4062+ self.assertEqual(e.exception.message,
4063 '@depends function needs the same `when` as '
4064 'options it depends on')
4065
4066@@ -868,7 +868,7 @@ class TestConfigure(unittest.TestCase):
4067 with self.assertRaises(ConfigureError) as e:
4068 self.get_config()
4069
4070- self.assertEquals(e.exception.message,
4071+ self.assertEqual(e.exception.message,
4072 '@depends function needs the same `when` as '
4073 'options it depends on')
4074
4075@@ -896,7 +896,7 @@ class TestConfigure(unittest.TestCase):
4076 with self.moz_configure('include("../foo.configure")'):
4077 self.get_config()
4078
4079- self.assertEquals(
4080+ self.assertEqual(
4081 e.exception.message,
4082 'Cannot include `%s` because it is not in a subdirectory of `%s`'
4083 % (mozpath.normpath(mozpath.join(test_data_path, '..',
4084@@ -911,7 +911,7 @@ class TestConfigure(unittest.TestCase):
4085 '''):
4086 self.get_config()
4087
4088- self.assertEquals(
4089+ self.assertEqual(
4090 e.exception.message,
4091 'Cannot include `%s` because it was included already.'
4092 % mozpath.normpath(mozpath.join(test_data_path,
4093@@ -924,7 +924,7 @@ class TestConfigure(unittest.TestCase):
4094 '''):
4095 self.get_config()
4096
4097- self.assertEquals(e.exception.message, "Unexpected type: 'int'")
4098+ self.assertEqual(e.exception.message, "Unexpected type: 'int'")
4099
4100 def test_include_when(self):
4101 with MockedOpen({
4102@@ -967,26 +967,26 @@ class TestConfigure(unittest.TestCase):
4103 '''),
4104 }):
4105 config = self.get_config()
4106- self.assertEquals(config, {})
4107+ self.assertEqual(config, {})
4108
4109 config = self.get_config(['--with-foo'])
4110- self.assertEquals(config, {})
4111+ self.assertEqual(config, {})
4112
4113 config = self.get_config(['--with-bar'])
4114- self.assertEquals(config, {
4115+ self.assertEqual(config, {
4116 'BAR': 'bar',
4117 })
4118
4119 with self.assertRaises(InvalidOptionError) as e:
4120 self.get_config(['--with-qux'])
4121
4122- self.assertEquals(
4123+ self.assertEqual(
4124 e.exception.message,
4125 '--with-qux is not available in this configuration'
4126 )
4127
4128 config = self.get_config(['--with-foo', '--with-foo-really'])
4129- self.assertEquals(config, {
4130+ self.assertEqual(config, {
4131 'FOO': 'foo',
4132 'FOO2': True,
4133 })
4134@@ -998,7 +998,7 @@ class TestConfigure(unittest.TestCase):
4135 '''):
4136 self.get_config()
4137
4138- self.assertEquals(e.exception.message, 'Cannot reassign builtins')
4139+ self.assertEqual(e.exception.message, 'Cannot reassign builtins')
4140
4141 with self.assertRaises(KeyError) as e:
4142 with self.moz_configure('''
4143@@ -1006,7 +1006,7 @@ class TestConfigure(unittest.TestCase):
4144 '''):
4145 self.get_config()
4146
4147- self.assertEquals(e.exception.message,
4148+ self.assertEqual(e.exception.message,
4149 'Cannot assign `foo` because it is neither a '
4150 '@depends nor a @template')
4151
4152@@ -1019,7 +1019,7 @@ class TestConfigure(unittest.TestCase):
4153 '''):
4154 self.get_config()
4155
4156- self.assertEquals(e.exception.message,
4157+ self.assertEqual(e.exception.message,
4158 "@depends needs at least one argument")
4159
4160 with self.assertRaises(ConfigureError) as e:
4161@@ -1030,7 +1030,7 @@ class TestConfigure(unittest.TestCase):
4162 '''):
4163 self.get_config()
4164
4165- self.assertEquals(e.exception.message,
4166+ self.assertEqual(e.exception.message,
4167 "'--with-foo' is not a known option. Maybe it's "
4168 "declared too late?")
4169
4170@@ -1042,7 +1042,7 @@ class TestConfigure(unittest.TestCase):
4171 '''):
4172 self.get_config()
4173
4174- self.assertEquals(e.exception.message,
4175+ self.assertEqual(e.exception.message,
4176 "Option must not contain an '='")
4177
4178 with self.assertRaises(TypeError) as e:
4179@@ -1053,7 +1053,7 @@ class TestConfigure(unittest.TestCase):
4180 '''):
4181 self.get_config()
4182
4183- self.assertEquals(e.exception.message,
4184+ self.assertEqual(e.exception.message,
4185 "Cannot use object of type 'int' as argument "
4186 "to @depends")
4187
4188@@ -1065,7 +1065,7 @@ class TestConfigure(unittest.TestCase):
4189 '''):
4190 self.get_config()
4191
4192- self.assertEquals(e.exception.message,
4193+ self.assertEqual(e.exception.message,
4194 "Cannot decorate generator functions with @depends")
4195
4196 with self.assertRaises(TypeError) as e:
4197@@ -1074,7 +1074,7 @@ class TestConfigure(unittest.TestCase):
4198 '''):
4199 self.get_config()
4200
4201- self.assertEquals(e.exception.message,
4202+ self.assertEqual(e.exception.message,
4203 "Unexpected type: 'int'")
4204
4205 with self.assertRaises(ConfigureError) as e:
4206@@ -1088,7 +1088,7 @@ class TestConfigure(unittest.TestCase):
4207 '''):
4208 self.get_config()
4209
4210- self.assertEquals(e.exception.message,
4211+ self.assertEqual(e.exception.message,
4212 "The `foo` function may not be called")
4213
4214 with self.assertRaises(TypeError) as e:
4215@@ -1099,7 +1099,7 @@ class TestConfigure(unittest.TestCase):
4216 '''):
4217 self.get_config()
4218
4219- self.assertEquals(e.exception.message,
4220+ self.assertEqual(e.exception.message,
4221 "depends_impl() got an unexpected keyword argument 'foo'")
4222
4223 def test_depends_when(self):
4224@@ -1124,12 +1124,12 @@ class TestConfigure(unittest.TestCase):
4225 set_config('QUX', qux)
4226 '''):
4227 config = self.get_config()
4228- self.assertEquals(config, {
4229+ self.assertEqual(config, {
4230 'FOO': 'foo',
4231 })
4232
4233 config = self.get_config(['--with-qux'])
4234- self.assertEquals(config, {
4235+ self.assertEqual(config, {
4236 'FOO': 'foo',
4237 'QUX': 'qux',
4238 })
4239@@ -1144,7 +1144,7 @@ class TestConfigure(unittest.TestCase):
4240 '''):
4241 self.get_config()
4242
4243- self.assertEquals(e.exception.message,
4244+ self.assertEqual(e.exception.message,
4245 '@imports must appear after @template')
4246
4247 with self.assertRaises(ConfigureError) as e:
4248@@ -1157,7 +1157,7 @@ class TestConfigure(unittest.TestCase):
4249 '''):
4250 self.get_config()
4251
4252- self.assertEquals(e.exception.message,
4253+ self.assertEqual(e.exception.message,
4254 '@imports must appear after @depends')
4255
4256 for import_ in (
4257@@ -1174,7 +1174,7 @@ class TestConfigure(unittest.TestCase):
4258 ''' % import_):
4259 self.get_config()
4260
4261- self.assertEquals(e.exception.message, "Unexpected type: 'int'")
4262+ self.assertEqual(e.exception.message, "Unexpected type: 'int'")
4263
4264 with self.assertRaises(TypeError) as e:
4265 with self.moz_configure('''
4266@@ -1185,7 +1185,7 @@ class TestConfigure(unittest.TestCase):
4267 '''):
4268 self.get_config()
4269
4270- self.assertEquals(e.exception.message, "Unexpected type: 'int'")
4271+ self.assertEqual(e.exception.message, "Unexpected type: 'int'")
4272
4273 with self.assertRaises(ValueError) as e:
4274 with self.moz_configure('''
4275@@ -1195,7 +1195,7 @@ class TestConfigure(unittest.TestCase):
4276 '''):
4277 self.get_config()
4278
4279- self.assertEquals(e.exception.message,
4280+ self.assertEqual(e.exception.message,
4281 "Invalid argument to @imports: 'os*'")
4282
4283 def test_only_when(self):
4284@@ -1250,7 +1250,7 @@ class TestConfigure(unittest.TestCase):
4285 with self.assertRaises(InvalidOptionError) as e:
4286 self.get_config(['--foo'])
4287
4288- self.assertEquals(e.exception.message,
4289+ self.assertEqual(e.exception.message,
4290 '--foo is not available in this configuration')
4291
4292 # Cannot depend on an option defined in a only_when block, because we
4293@@ -1261,7 +1261,7 @@ class TestConfigure(unittest.TestCase):
4294 with self.assertRaises(ConfigureError) as e:
4295 self.get_config()
4296
4297- self.assertEquals(e.exception.message,
4298+ self.assertEqual(e.exception.message,
4299 '@depends function needs the same `when` as '
4300 'options it depends on')
4301
4302@@ -1278,7 +1278,7 @@ class TestConfigure(unittest.TestCase):
4303 with self.assertRaises(InvalidOptionError) as e:
4304 self.get_config()
4305
4306- self.assertEquals(e.exception.message,
4307+ self.assertEqual(e.exception.message,
4308 '--foo is not available in this configuration')
4309
4310 # And similarly doesn't fail when the condition is true.
4311diff --git a/python/mozbuild/mozbuild/test/configure/test_lint.py b/python/mozbuild/mozbuild/test/configure/test_lint.py
4312index 6d8d4c49f..6ad897839 100644
4313--- a/python/mozbuild/mozbuild/test/configure/test_lint.py
4314+++ b/python/mozbuild/mozbuild/test/configure/test_lint.py
4315@@ -2,9 +2,9 @@
4316 # License, v. 2.0. If a copy of the MPL was not distributed with this
4317 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4318
4319-from __future__ import absolute_import, print_function, unicode_literals
4320
4321-from StringIO import StringIO
4322+
4323+from io import StringIO
4324 import os
4325 import textwrap
4326 import unittest
4327@@ -62,7 +62,7 @@ class TestLint(unittest.TestCase):
4328 '''):
4329 self.lint_test()
4330
4331- self.assertEquals(e.exception.message,
4332+ self.assertEqual(e.exception.message,
4333 "`bar` depends on '--help' and `foo`. "
4334 "`foo` must depend on '--help'")
4335
4336@@ -85,7 +85,7 @@ class TestLint(unittest.TestCase):
4337 '''):
4338 self.lint_test()
4339
4340- self.assertEquals(e.exception.message,
4341+ self.assertEqual(e.exception.message,
4342 "`bar` depends on '--help' and `foo`. "
4343 "`foo` must depend on '--help'")
4344
4345@@ -111,7 +111,7 @@ class TestLint(unittest.TestCase):
4346 '''):
4347 self.lint_test()
4348
4349- self.assertEquals(e.exception.message,
4350+ self.assertEqual(e.exception.message,
4351 "Missing @depends for `foo`: '--help'")
4352
4353 with self.assertRaises(ConfigureError) as e:
4354@@ -130,7 +130,7 @@ class TestLint(unittest.TestCase):
4355 '''):
4356 self.lint_test()
4357
4358- self.assertEquals(e.exception.message,
4359+ self.assertEqual(e.exception.message,
4360 "Missing @depends for `foo`: '--help'")
4361
4362 with self.assertRaises(ConfigureError) as e:
4363@@ -145,7 +145,7 @@ class TestLint(unittest.TestCase):
4364 '''):
4365 self.lint_test()
4366
4367- self.assertEquals(e.exception.message,
4368+ self.assertEqual(e.exception.message,
4369 "Missing @depends for `foo`: '--help'")
4370
4371 # This would have failed with "Missing @depends for `foo`: '--help'"
4372@@ -178,7 +178,7 @@ class TestLint(unittest.TestCase):
4373 '''):
4374 self.lint_test()
4375
4376- self.assertEquals(e.exception.message,
4377+ self.assertEqual(e.exception.message,
4378 "Missing @depends for `foo`: '--help'")
4379
4380 # There is a default restricted `os` module when there is no explicit
4381@@ -205,7 +205,7 @@ class TestLint(unittest.TestCase):
4382 '''):
4383 self.lint_test()
4384
4385- self.assertEquals(e.exception.message,
4386+ self.assertEqual(e.exception.message,
4387 "%s:3: The dependency on `--foo` is unused."
4388 % mozpath.join(test_data_path, 'moz.configure'))
4389
4390@@ -222,7 +222,7 @@ class TestLint(unittest.TestCase):
4391 '''):
4392 self.lint_test()
4393
4394- self.assertEquals(e.exception.message,
4395+ self.assertEqual(e.exception.message,
4396 "%s:5: The dependency on `bar` is unused."
4397 % mozpath.join(test_data_path, 'moz.configure'))
4398
4399@@ -236,7 +236,7 @@ class TestLint(unittest.TestCase):
4400 '''):
4401 self.lint_test()
4402
4403- self.assertEquals(e.exception.message,
4404+ self.assertEqual(e.exception.message,
4405 "%s:2: The dependency on `<lambda>` is unused."
4406 % mozpath.join(test_data_path, 'moz.configure'))
4407
4408@@ -257,7 +257,7 @@ class TestLint(unittest.TestCase):
4409 '''):
4410 self.lint_test()
4411
4412- self.assertEquals(e.exception.message,
4413+ self.assertEqual(e.exception.message,
4414 "%s:9: The dependency on `qux` is unused."
4415 % mozpath.join(test_data_path, 'moz.configure'))
4416
4417diff --git a/python/mozbuild/mozbuild/test/configure/test_moz_configure.py b/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
4418index b3342e268..7a26e9e09 100644
4419--- a/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
4420+++ b/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
4421@@ -2,7 +2,7 @@
4422 # License, v. 2.0. If a copy of the MPL was not distributed with this
4423 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4424
4425-from __future__ import absolute_import, print_function, unicode_literals
4426+
4427
4428 from mozunit import main
4429 from mozpack import path as mozpath
4430@@ -27,10 +27,10 @@ class TestMozConfigure(BaseConfigureTest):
4431 shell = mozpath.abspath('/bin/sh')
4432 return result.replace('CONFIG_SHELL=%s ' % shell, '')
4433
4434- self.assertEquals('--enable-application=browser',
4435+ self.assertEqual('--enable-application=browser',
4436 get_value_for(['--enable-application=browser']))
4437
4438- self.assertEquals('--enable-application=browser '
4439+ self.assertEqual('--enable-application=browser '
4440 'MOZ_VTUNE=1',
4441 get_value_for(['--enable-application=browser',
4442 'MOZ_VTUNE=1']))
4443@@ -39,25 +39,25 @@ class TestMozConfigure(BaseConfigureTest):
4444 environ={'MOZ_VTUNE': '1'},
4445 mozconfig='ac_add_options --enable-project=js')
4446
4447- self.assertEquals('--enable-project=js MOZ_VTUNE=1',
4448+ self.assertEqual('--enable-project=js MOZ_VTUNE=1',
4449 value)
4450
4451 # --disable-js-shell is the default, so it's filtered out.
4452- self.assertEquals('--enable-application=browser',
4453+ self.assertEqual('--enable-application=browser',
4454 get_value_for(['--enable-application=browser',
4455 '--disable-js-shell']))
4456
4457 # Normally, --without-foo would be filtered out because that's the
4458 # default, but since it is a (fake) old-configure option, it always
4459 # appears.
4460- self.assertEquals('--enable-application=browser --without-foo',
4461+ self.assertEqual('--enable-application=browser --without-foo',
4462 get_value_for(['--enable-application=browser',
4463 '--without-foo']))
4464- self.assertEquals('--enable-application=browser --with-foo',
4465+ self.assertEqual('--enable-application=browser --with-foo',
4466 get_value_for(['--enable-application=browser',
4467 '--with-foo']))
4468
4469- self.assertEquals("--enable-application=browser '--with-foo=foo bar'",
4470+ self.assertEqual("--enable-application=browser '--with-foo=foo bar'",
4471 get_value_for(['--enable-application=browser',
4472 '--with-foo=foo bar']))
4473
4474@@ -69,7 +69,7 @@ class TestMozConfigure(BaseConfigureTest):
4475 self.version = version
4476
4477 def __call__(self, stdin, args):
4478- this.assertEquals(args, ('-version',))
4479+ this.assertEqual(args, ('-version',))
4480 return 0, self.version, ''
4481
4482 def check_nsis_version(version):
4483@@ -84,13 +84,13 @@ class TestMozConfigure(BaseConfigureTest):
4484 with self.assertRaises(SystemExit) as e:
4485 check_nsis_version('v3.0a2')
4486
4487- self.assertEquals(check_nsis_version('v3.0b1'), '3.0b1')
4488- self.assertEquals(check_nsis_version('v3.0b2'), '3.0b2')
4489- self.assertEquals(check_nsis_version('v3.0rc1'), '3.0rc1')
4490- self.assertEquals(check_nsis_version('v3.0'), '3.0')
4491- self.assertEquals(check_nsis_version('v3.0-2'), '3.0')
4492- self.assertEquals(check_nsis_version('v3.0.1'), '3.0')
4493- self.assertEquals(check_nsis_version('v3.1'), '3.1')
4494+ self.assertEqual(check_nsis_version('v3.0b1'), '3.0b1')
4495+ self.assertEqual(check_nsis_version('v3.0b2'), '3.0b2')
4496+ self.assertEqual(check_nsis_version('v3.0rc1'), '3.0rc1')
4497+ self.assertEqual(check_nsis_version('v3.0'), '3.0')
4498+ self.assertEqual(check_nsis_version('v3.0-2'), '3.0')
4499+ self.assertEqual(check_nsis_version('v3.0.1'), '3.0')
4500+ self.assertEqual(check_nsis_version('v3.1'), '3.1')
4501
4502
4503 if __name__ == '__main__':
4504diff --git a/python/mozbuild/mozbuild/test/configure/test_options.py b/python/mozbuild/mozbuild/test/configure/test_options.py
4505index 9defccb2c..330ce3b1f 100644
4506--- a/python/mozbuild/mozbuild/test/configure/test_options.py
4507+++ b/python/mozbuild/mozbuild/test/configure/test_options.py
4508@@ -2,7 +2,7 @@
4509 # License, v. 2.0. If a copy of the MPL was not distributed with this
4510 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4511
4512-from __future__ import absolute_import, print_function, unicode_literals
4513+
4514
4515 import unittest
4516
4517@@ -28,139 +28,139 @@ class Option(Option):
4518 class TestOption(unittest.TestCase):
4519 def test_option(self):
4520 option = Option('--option')
4521- self.assertEquals(option.prefix, '')
4522- self.assertEquals(option.name, 'option')
4523- self.assertEquals(option.env, None)
4524+ self.assertEqual(option.prefix, '')
4525+ self.assertEqual(option.name, 'option')
4526+ self.assertEqual(option.env, None)
4527 self.assertFalse(option.default)
4528
4529 option = Option('--enable-option')
4530- self.assertEquals(option.prefix, 'enable')
4531- self.assertEquals(option.name, 'option')
4532- self.assertEquals(option.env, None)
4533+ self.assertEqual(option.prefix, 'enable')
4534+ self.assertEqual(option.name, 'option')
4535+ self.assertEqual(option.env, None)
4536 self.assertFalse(option.default)
4537
4538 option = Option('--disable-option')
4539- self.assertEquals(option.prefix, 'disable')
4540- self.assertEquals(option.name, 'option')
4541- self.assertEquals(option.env, None)
4542+ self.assertEqual(option.prefix, 'disable')
4543+ self.assertEqual(option.name, 'option')
4544+ self.assertEqual(option.env, None)
4545 self.assertTrue(option.default)
4546
4547 option = Option('--with-option')
4548- self.assertEquals(option.prefix, 'with')
4549- self.assertEquals(option.name, 'option')
4550- self.assertEquals(option.env, None)
4551+ self.assertEqual(option.prefix, 'with')
4552+ self.assertEqual(option.name, 'option')
4553+ self.assertEqual(option.env, None)
4554 self.assertFalse(option.default)
4555
4556 option = Option('--without-option')
4557- self.assertEquals(option.prefix, 'without')
4558- self.assertEquals(option.name, 'option')
4559- self.assertEquals(option.env, None)
4560+ self.assertEqual(option.prefix, 'without')
4561+ self.assertEqual(option.name, 'option')
4562+ self.assertEqual(option.env, None)
4563 self.assertTrue(option.default)
4564
4565 option = Option('--without-option-foo', env='MOZ_OPTION')
4566- self.assertEquals(option.env, 'MOZ_OPTION')
4567+ self.assertEqual(option.env, 'MOZ_OPTION')
4568
4569 option = Option(env='MOZ_OPTION')
4570- self.assertEquals(option.prefix, '')
4571- self.assertEquals(option.name, None)
4572- self.assertEquals(option.env, 'MOZ_OPTION')
4573+ self.assertEqual(option.prefix, '')
4574+ self.assertEqual(option.name, None)
4575+ self.assertEqual(option.env, 'MOZ_OPTION')
4576 self.assertFalse(option.default)
4577
4578 with self.assertRaises(InvalidOptionError) as e:
4579 Option('--option', nargs=0, default=('a',))
4580- self.assertEquals(e.exception.message,
4581+ self.assertEqual(e.exception.message,
4582 "The given `default` doesn't satisfy `nargs`")
4583
4584 with self.assertRaises(InvalidOptionError) as e:
4585 Option('--option', nargs=1, default=())
4586- self.assertEquals(
4587+ self.assertEqual(
4588 e.exception.message,
4589 'default must be a bool, a string or a tuple of strings')
4590
4591 with self.assertRaises(InvalidOptionError) as e:
4592 Option('--option', nargs=1, default=True)
4593- self.assertEquals(e.exception.message,
4594+ self.assertEqual(e.exception.message,
4595 "The given `default` doesn't satisfy `nargs`")
4596
4597 with self.assertRaises(InvalidOptionError) as e:
4598 Option('--option', nargs=1, default=('a', 'b'))
4599- self.assertEquals(e.exception.message,
4600+ self.assertEqual(e.exception.message,
4601 "The given `default` doesn't satisfy `nargs`")
4602
4603 with self.assertRaises(InvalidOptionError) as e:
4604 Option('--option', nargs=2, default=())
4605- self.assertEquals(
4606+ self.assertEqual(
4607 e.exception.message,
4608 'default must be a bool, a string or a tuple of strings')
4609
4610 with self.assertRaises(InvalidOptionError) as e:
4611 Option('--option', nargs=2, default=True)
4612- self.assertEquals(e.exception.message,
4613+ self.assertEqual(e.exception.message,
4614 "The given `default` doesn't satisfy `nargs`")
4615
4616 with self.assertRaises(InvalidOptionError) as e:
4617 Option('--option', nargs=2, default=('a',))
4618- self.assertEquals(e.exception.message,
4619+ self.assertEqual(e.exception.message,
4620 "The given `default` doesn't satisfy `nargs`")
4621
4622 with self.assertRaises(InvalidOptionError) as e:
4623 Option('--option', nargs='?', default=('a', 'b'))
4624- self.assertEquals(e.exception.message,
4625+ self.assertEqual(e.exception.message,
4626 "The given `default` doesn't satisfy `nargs`")
4627
4628 with self.assertRaises(InvalidOptionError) as e:
4629 Option('--option', nargs='+', default=())
4630- self.assertEquals(
4631+ self.assertEqual(
4632 e.exception.message,
4633 'default must be a bool, a string or a tuple of strings')
4634
4635 with self.assertRaises(InvalidOptionError) as e:
4636 Option('--option', nargs='+', default=True)
4637- self.assertEquals(e.exception.message,
4638+ self.assertEqual(e.exception.message,
4639 "The given `default` doesn't satisfy `nargs`")
4640
4641 # --disable options with a nargs value that requires at least one
4642 # argument need to be given a default.
4643 with self.assertRaises(InvalidOptionError) as e:
4644 Option('--disable-option', nargs=1)
4645- self.assertEquals(e.exception.message,
4646+ self.assertEqual(e.exception.message,
4647 "The given `default` doesn't satisfy `nargs`")
4648
4649 with self.assertRaises(InvalidOptionError) as e:
4650 Option('--disable-option', nargs='+')
4651- self.assertEquals(e.exception.message,
4652+ self.assertEqual(e.exception.message,
4653 "The given `default` doesn't satisfy `nargs`")
4654
4655 # Test nargs inference from default value
4656 option = Option('--with-foo', default=True)
4657- self.assertEquals(option.nargs, 0)
4658+ self.assertEqual(option.nargs, 0)
4659
4660 option = Option('--with-foo', default=False)
4661- self.assertEquals(option.nargs, 0)
4662+ self.assertEqual(option.nargs, 0)
4663
4664 option = Option('--with-foo', default='a')
4665- self.assertEquals(option.nargs, '?')
4666+ self.assertEqual(option.nargs, '?')
4667
4668 option = Option('--with-foo', default=('a',))
4669- self.assertEquals(option.nargs, '?')
4670+ self.assertEqual(option.nargs, '?')
4671
4672 option = Option('--with-foo', default=('a', 'b'))
4673- self.assertEquals(option.nargs, '*')
4674+ self.assertEqual(option.nargs, '*')
4675
4676 option = Option(env='FOO', default=True)
4677- self.assertEquals(option.nargs, 0)
4678+ self.assertEqual(option.nargs, 0)
4679
4680 option = Option(env='FOO', default=False)
4681- self.assertEquals(option.nargs, 0)
4682+ self.assertEqual(option.nargs, 0)
4683
4684 option = Option(env='FOO', default='a')
4685- self.assertEquals(option.nargs, '?')
4686+ self.assertEqual(option.nargs, '?')
4687
4688 option = Option(env='FOO', default=('a',))
4689- self.assertEquals(option.nargs, '?')
4690+ self.assertEqual(option.nargs, '?')
4691
4692 option = Option(env='FOO', default=('a', 'b'))
4693- self.assertEquals(option.nargs, '*')
4694+ self.assertEqual(option.nargs, '*')
4695
4696 def test_option_option(self):
4697 for option in (
4698@@ -170,70 +170,70 @@ class TestOption(unittest.TestCase):
4699 '--with-option',
4700 '--without-option',
4701 ):
4702- self.assertEquals(Option(option).option, option)
4703- self.assertEquals(Option(option, env='FOO').option, option)
4704+ self.assertEqual(Option(option).option, option)
4705+ self.assertEqual(Option(option, env='FOO').option, option)
4706
4707 opt = Option(option, default=False)
4708- self.assertEquals(opt.option,
4709+ self.assertEqual(opt.option,
4710 option.replace('-disable-', '-enable-')
4711 .replace('-without-', '-with-'))
4712
4713 opt = Option(option, default=True)
4714- self.assertEquals(opt.option,
4715+ self.assertEqual(opt.option,
4716 option.replace('-enable-', '-disable-')
4717 .replace('-with-', '-without-'))
4718
4719- self.assertEquals(Option(env='FOO').option, 'FOO')
4720+ self.assertEqual(Option(env='FOO').option, 'FOO')
4721
4722 def test_option_choices(self):
4723 with self.assertRaises(InvalidOptionError) as e:
4724 Option('--option', nargs=3, choices=('a', 'b'))
4725- self.assertEquals(e.exception.message,
4726+ self.assertEqual(e.exception.message,
4727 'Not enough `choices` for `nargs`')
4728
4729 with self.assertRaises(InvalidOptionError) as e:
4730 Option('--without-option', nargs=1, choices=('a', 'b'))
4731- self.assertEquals(e.exception.message,
4732+ self.assertEqual(e.exception.message,
4733 'A `default` must be given along with `choices`')
4734
4735 with self.assertRaises(InvalidOptionError) as e:
4736 Option('--without-option', nargs='+', choices=('a', 'b'))
4737- self.assertEquals(e.exception.message,
4738+ self.assertEqual(e.exception.message,
4739 'A `default` must be given along with `choices`')
4740
4741 with self.assertRaises(InvalidOptionError) as e:
4742 Option('--without-option', default='c', choices=('a', 'b'))
4743- self.assertEquals(e.exception.message,
4744+ self.assertEqual(e.exception.message,
4745 "The `default` value must be one of 'a', 'b'")
4746
4747 with self.assertRaises(InvalidOptionError) as e:
4748 Option('--without-option', default=('a', 'c',), choices=('a', 'b'))
4749- self.assertEquals(e.exception.message,
4750+ self.assertEqual(e.exception.message,
4751 "The `default` value must be one of 'a', 'b'")
4752
4753 with self.assertRaises(InvalidOptionError) as e:
4754 Option('--without-option', default=('c',), choices=('a', 'b'))
4755- self.assertEquals(e.exception.message,
4756+ self.assertEqual(e.exception.message,
4757 "The `default` value must be one of 'a', 'b'")
4758
4759 option = Option('--with-option', nargs='+', choices=('a', 'b'))
4760 with self.assertRaises(InvalidOptionError) as e:
4761 option.get_value('--with-option=c')
4762- self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
4763+ self.assertEqual(e.exception.message, "'c' is not one of 'a', 'b'")
4764
4765 value = option.get_value('--with-option=b,a')
4766 self.assertTrue(value)
4767- self.assertEquals(PositiveOptionValue(('b', 'a')), value)
4768+ self.assertEqual(PositiveOptionValue(('b', 'a')), value)
4769
4770 option = Option('--without-option', nargs='*', default='a',
4771 choices=('a', 'b'))
4772 with self.assertRaises(InvalidOptionError) as e:
4773 option.get_value('--with-option=c')
4774- self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
4775+ self.assertEqual(e.exception.message, "'c' is not one of 'a', 'b'")
4776
4777 value = option.get_value('--with-option=b,a')
4778 self.assertTrue(value)
4779- self.assertEquals(PositiveOptionValue(('b', 'a')), value)
4780+ self.assertEqual(PositiveOptionValue(('b', 'a')), value)
4781
4782 # Test nargs inference from choices
4783 option = Option('--with-option', choices=('a', 'b'))
4784@@ -244,37 +244,37 @@ class TestOption(unittest.TestCase):
4785 choices=('a', 'b', 'c', 'd'))
4786
4787 value = option.get_value('--with-option=+d')
4788- self.assertEquals(PositiveOptionValue(('b', 'c', 'd')), value)
4789+ self.assertEqual(PositiveOptionValue(('b', 'c', 'd')), value)
4790
4791 value = option.get_value('--with-option=-b')
4792- self.assertEquals(PositiveOptionValue(('c',)), value)
4793+ self.assertEqual(PositiveOptionValue(('c',)), value)
4794
4795 value = option.get_value('--with-option=-b,+d')
4796- self.assertEquals(PositiveOptionValue(('c','d')), value)
4797+ self.assertEqual(PositiveOptionValue(('c','d')), value)
4798
4799 # Adding something that is in the default is fine
4800 value = option.get_value('--with-option=+b')
4801- self.assertEquals(PositiveOptionValue(('b', 'c')), value)
4802+ self.assertEqual(PositiveOptionValue(('b', 'c')), value)
4803
4804 # Removing something that is not in the default is fine, as long as it
4805 # is one of the choices
4806 value = option.get_value('--with-option=-a')
4807- self.assertEquals(PositiveOptionValue(('b', 'c')), value)
4808+ self.assertEqual(PositiveOptionValue(('b', 'c')), value)
4809
4810 with self.assertRaises(InvalidOptionError) as e:
4811 option.get_value('--with-option=-e')
4812- self.assertEquals(e.exception.message,
4813+ self.assertEqual(e.exception.message,
4814 "'e' is not one of 'a', 'b', 'c', 'd'")
4815
4816 # Other "not a choice" errors.
4817 with self.assertRaises(InvalidOptionError) as e:
4818 option.get_value('--with-option=+e')
4819- self.assertEquals(e.exception.message,
4820+ self.assertEqual(e.exception.message,
4821 "'e' is not one of 'a', 'b', 'c', 'd'")
4822
4823 with self.assertRaises(InvalidOptionError) as e:
4824 option.get_value('--with-option=e')
4825- self.assertEquals(e.exception.message,
4826+ self.assertEqual(e.exception.message,
4827 "'e' is not one of 'a', 'b', 'c', 'd'")
4828
4829 def test_option_value_compare(self):
4830@@ -294,7 +294,7 @@ class TestOption(unittest.TestCase):
4831
4832 # For usability reasons, we raise TypeError when attempting to compare
4833 # against a non-tuple.
4834- with self.assertRaisesRegexp(TypeError, 'cannot compare a'):
4835+ with self.assertRaisesRegex(TypeError, 'cannot compare a'):
4836 val == 'foo'
4837
4838 # But we allow empty option values to compare otherwise we can't
4839@@ -313,36 +313,36 @@ class TestOption(unittest.TestCase):
4840
4841 def test_option_value_format(self):
4842 val = PositiveOptionValue()
4843- self.assertEquals('--with-value', val.format('--with-value'))
4844- self.assertEquals('--with-value', val.format('--without-value'))
4845- self.assertEquals('--enable-value', val.format('--enable-value'))
4846- self.assertEquals('--enable-value', val.format('--disable-value'))
4847- self.assertEquals('--value', val.format('--value'))
4848- self.assertEquals('VALUE=1', val.format('VALUE'))
4849+ self.assertEqual('--with-value', val.format('--with-value'))
4850+ self.assertEqual('--with-value', val.format('--without-value'))
4851+ self.assertEqual('--enable-value', val.format('--enable-value'))
4852+ self.assertEqual('--enable-value', val.format('--disable-value'))
4853+ self.assertEqual('--value', val.format('--value'))
4854+ self.assertEqual('VALUE=1', val.format('VALUE'))
4855
4856 val = PositiveOptionValue(('a',))
4857- self.assertEquals('--with-value=a', val.format('--with-value'))
4858- self.assertEquals('--with-value=a', val.format('--without-value'))
4859- self.assertEquals('--enable-value=a', val.format('--enable-value'))
4860- self.assertEquals('--enable-value=a', val.format('--disable-value'))
4861- self.assertEquals('--value=a', val.format('--value'))
4862- self.assertEquals('VALUE=a', val.format('VALUE'))
4863+ self.assertEqual('--with-value=a', val.format('--with-value'))
4864+ self.assertEqual('--with-value=a', val.format('--without-value'))
4865+ self.assertEqual('--enable-value=a', val.format('--enable-value'))
4866+ self.assertEqual('--enable-value=a', val.format('--disable-value'))
4867+ self.assertEqual('--value=a', val.format('--value'))
4868+ self.assertEqual('VALUE=a', val.format('VALUE'))
4869
4870 val = PositiveOptionValue(('a', 'b'))
4871- self.assertEquals('--with-value=a,b', val.format('--with-value'))
4872- self.assertEquals('--with-value=a,b', val.format('--without-value'))
4873- self.assertEquals('--enable-value=a,b', val.format('--enable-value'))
4874- self.assertEquals('--enable-value=a,b', val.format('--disable-value'))
4875- self.assertEquals('--value=a,b', val.format('--value'))
4876- self.assertEquals('VALUE=a,b', val.format('VALUE'))
4877+ self.assertEqual('--with-value=a,b', val.format('--with-value'))
4878+ self.assertEqual('--with-value=a,b', val.format('--without-value'))
4879+ self.assertEqual('--enable-value=a,b', val.format('--enable-value'))
4880+ self.assertEqual('--enable-value=a,b', val.format('--disable-value'))
4881+ self.assertEqual('--value=a,b', val.format('--value'))
4882+ self.assertEqual('VALUE=a,b', val.format('VALUE'))
4883
4884 val = NegativeOptionValue()
4885- self.assertEquals('--without-value', val.format('--with-value'))
4886- self.assertEquals('--without-value', val.format('--without-value'))
4887- self.assertEquals('--disable-value', val.format('--enable-value'))
4888- self.assertEquals('--disable-value', val.format('--disable-value'))
4889- self.assertEquals('', val.format('--value'))
4890- self.assertEquals('VALUE=', val.format('VALUE'))
4891+ self.assertEqual('--without-value', val.format('--with-value'))
4892+ self.assertEqual('--without-value', val.format('--without-value'))
4893+ self.assertEqual('--disable-value', val.format('--enable-value'))
4894+ self.assertEqual('--disable-value', val.format('--disable-value'))
4895+ self.assertEqual('', val.format('--value'))
4896+ self.assertEqual('VALUE=', val.format('VALUE'))
4897
4898 def test_option_value(self, name='option', nargs=0, default=None):
4899 disabled = name.startswith(('disable-', 'without-'))
4900@@ -359,28 +359,28 @@ class TestOption(unittest.TestCase):
4901
4902 if nargs in (0, '?', '*') or disabled:
4903 value = option.get_value('--%s' % name, 'option')
4904- self.assertEquals(value, posOptionValue())
4905- self.assertEquals(value.origin, 'option')
4906+ self.assertEqual(value, posOptionValue())
4907+ self.assertEqual(value.origin, 'option')
4908 else:
4909 with self.assertRaises(InvalidOptionError) as e:
4910 option.get_value('--%s' % name)
4911 if nargs == 1:
4912- self.assertEquals(e.exception.message,
4913+ self.assertEqual(e.exception.message,
4914 '--%s takes 1 value' % name)
4915 elif nargs == '+':
4916- self.assertEquals(e.exception.message,
4917+ self.assertEqual(e.exception.message,
4918 '--%s takes 1 or more values' % name)
4919 else:
4920- self.assertEquals(e.exception.message,
4921+ self.assertEqual(e.exception.message,
4922 '--%s takes 2 values' % name)
4923
4924 value = option.get_value('')
4925- self.assertEquals(value, defaultValue)
4926- self.assertEquals(value.origin, 'default')
4927+ self.assertEqual(value, defaultValue)
4928+ self.assertEqual(value.origin, 'default')
4929
4930 value = option.get_value(None)
4931- self.assertEquals(value, defaultValue)
4932- self.assertEquals(value.origin, 'default')
4933+ self.assertEqual(value, defaultValue)
4934+ self.assertEqual(value.origin, 'default')
4935
4936 with self.assertRaises(AssertionError):
4937 value = option.get_value('MOZ_OPTION=', 'environment')
4938@@ -393,47 +393,47 @@ class TestOption(unittest.TestCase):
4939
4940 if nargs in (1, '?', '*', '+') and not disabled:
4941 value = option.get_value('--%s=' % name, 'option')
4942- self.assertEquals(value, PositiveOptionValue(('',)))
4943- self.assertEquals(value.origin, 'option')
4944+ self.assertEqual(value, PositiveOptionValue(('',)))
4945+ self.assertEqual(value.origin, 'option')
4946 else:
4947 with self.assertRaises(InvalidOptionError) as e:
4948 option.get_value('--%s=' % name)
4949 if disabled:
4950- self.assertEquals(e.exception.message,
4951+ self.assertEqual(e.exception.message,
4952 'Cannot pass a value to --%s' % name)
4953 else:
4954- self.assertEquals(e.exception.message,
4955+ self.assertEqual(e.exception.message,
4956 '--%s takes %d values' % (name, nargs))
4957
4958 if nargs in (1, '?', '*', '+') and not disabled:
4959 value = option.get_value('--%s=foo' % name, 'option')
4960- self.assertEquals(value, PositiveOptionValue(('foo',)))
4961- self.assertEquals(value.origin, 'option')
4962+ self.assertEqual(value, PositiveOptionValue(('foo',)))
4963+ self.assertEqual(value.origin, 'option')
4964 else:
4965 with self.assertRaises(InvalidOptionError) as e:
4966 option.get_value('--%s=foo' % name)
4967 if disabled:
4968- self.assertEquals(e.exception.message,
4969+ self.assertEqual(e.exception.message,
4970 'Cannot pass a value to --%s' % name)
4971 else:
4972- self.assertEquals(e.exception.message,
4973+ self.assertEqual(e.exception.message,
4974 '--%s takes %d values' % (name, nargs))
4975
4976 if nargs in (2, '*', '+') and not disabled:
4977 value = option.get_value('--%s=foo,bar' % name, 'option')
4978- self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
4979- self.assertEquals(value.origin, 'option')
4980+ self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
4981+ self.assertEqual(value.origin, 'option')
4982 else:
4983 with self.assertRaises(InvalidOptionError) as e:
4984 option.get_value('--%s=foo,bar' % name, 'option')
4985 if disabled:
4986- self.assertEquals(e.exception.message,
4987+ self.assertEqual(e.exception.message,
4988 'Cannot pass a value to --%s' % name)
4989 elif nargs == '?':
4990- self.assertEquals(e.exception.message,
4991+ self.assertEqual(e.exception.message,
4992 '--%s takes 0 or 1 values' % name)
4993 else:
4994- self.assertEquals(e.exception.message,
4995+ self.assertEqual(e.exception.message,
4996 '--%s takes %d value%s'
4997 % (name, nargs, 's' if nargs != 1 else ''))
4998
4999@@ -441,59 +441,59 @@ class TestOption(unittest.TestCase):
5000 default=default)
5001 if nargs in (0, '?', '*') or disabled:
5002 value = option.get_value('--%s' % name, 'option')
5003- self.assertEquals(value, posOptionValue())
5004- self.assertEquals(value.origin, 'option')
5005+ self.assertEqual(value, posOptionValue())
5006+ self.assertEqual(value.origin, 'option')
5007 else:
5008 with self.assertRaises(InvalidOptionError) as e:
5009 option.get_value('--%s' % name)
5010 if disabled:
5011- self.assertEquals(e.exception.message,
5012+ self.assertEqual(e.exception.message,
5013 'Cannot pass a value to --%s' % name)
5014 elif nargs == '+':
5015- self.assertEquals(e.exception.message,
5016+ self.assertEqual(e.exception.message,
5017 '--%s takes 1 or more values' % name)
5018 else:
5019- self.assertEquals(e.exception.message,
5020+ self.assertEqual(e.exception.message,
5021 '--%s takes %d value%s'
5022 % (name, nargs, 's' if nargs != 1 else ''))
5023
5024 value = option.get_value('')
5025- self.assertEquals(value, defaultValue)
5026- self.assertEquals(value.origin, 'default')
5027+ self.assertEqual(value, defaultValue)
5028+ self.assertEqual(value.origin, 'default')
5029
5030 value = option.get_value(None)
5031- self.assertEquals(value, defaultValue)
5032- self.assertEquals(value.origin, 'default')
5033+ self.assertEqual(value, defaultValue)
5034+ self.assertEqual(value.origin, 'default')
5035
5036 value = option.get_value('MOZ_OPTION=', 'environment')
5037- self.assertEquals(value, NegativeOptionValue())
5038- self.assertEquals(value.origin, 'environment')
5039+ self.assertEqual(value, NegativeOptionValue())
5040+ self.assertEqual(value.origin, 'environment')
5041
5042 if nargs in (0, '?', '*'):
5043 value = option.get_value('MOZ_OPTION=1', 'environment')
5044- self.assertEquals(value, PositiveOptionValue())
5045- self.assertEquals(value.origin, 'environment')
5046+ self.assertEqual(value, PositiveOptionValue())
5047+ self.assertEqual(value.origin, 'environment')
5048 elif nargs in (1, '+'):
5049 value = option.get_value('MOZ_OPTION=1', 'environment')
5050- self.assertEquals(value, PositiveOptionValue(('1',)))
5051- self.assertEquals(value.origin, 'environment')
5052+ self.assertEqual(value, PositiveOptionValue(('1',)))
5053+ self.assertEqual(value.origin, 'environment')
5054 else:
5055 with self.assertRaises(InvalidOptionError) as e:
5056 option.get_value('MOZ_OPTION=1', 'environment')
5057- self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
5058+ self.assertEqual(e.exception.message, 'MOZ_OPTION takes 2 values')
5059
5060 if nargs in (1, '?', '*', '+') and not disabled:
5061 value = option.get_value('--%s=' % name, 'option')
5062- self.assertEquals(value, PositiveOptionValue(('',)))
5063- self.assertEquals(value.origin, 'option')
5064+ self.assertEqual(value, PositiveOptionValue(('',)))
5065+ self.assertEqual(value.origin, 'option')
5066 else:
5067 with self.assertRaises(InvalidOptionError) as e:
5068 option.get_value('--%s=' % name, 'option')
5069 if disabled:
5070- self.assertEquals(e.exception.message,
5071+ self.assertEqual(e.exception.message,
5072 'Cannot pass a value to --%s' % name)
5073 else:
5074- self.assertEquals(e.exception.message,
5075+ self.assertEqual(e.exception.message,
5076 '--%s takes %d values' % (name, nargs))
5077
5078 with self.assertRaises(AssertionError):
5079@@ -501,26 +501,26 @@ class TestOption(unittest.TestCase):
5080
5081 if nargs in (1, '?', '*', '+'):
5082 value = option.get_value('MOZ_OPTION=foo', 'environment')
5083- self.assertEquals(value, PositiveOptionValue(('foo',)))
5084- self.assertEquals(value.origin, 'environment')
5085+ self.assertEqual(value, PositiveOptionValue(('foo',)))
5086+ self.assertEqual(value.origin, 'environment')
5087 else:
5088 with self.assertRaises(InvalidOptionError) as e:
5089 option.get_value('MOZ_OPTION=foo', 'environment')
5090- self.assertEquals(e.exception.message,
5091+ self.assertEqual(e.exception.message,
5092 'MOZ_OPTION takes %d values' % nargs)
5093
5094 if nargs in (2, '*', '+'):
5095 value = option.get_value('MOZ_OPTION=foo,bar', 'environment')
5096- self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
5097- self.assertEquals(value.origin, 'environment')
5098+ self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
5099+ self.assertEqual(value.origin, 'environment')
5100 else:
5101 with self.assertRaises(InvalidOptionError) as e:
5102 option.get_value('MOZ_OPTION=foo,bar', 'environment')
5103 if nargs == '?':
5104- self.assertEquals(e.exception.message,
5105+ self.assertEqual(e.exception.message,
5106 'MOZ_OPTION takes 0 or 1 values')
5107 else:
5108- self.assertEquals(e.exception.message,
5109+ self.assertEqual(e.exception.message,
5110 'MOZ_OPTION takes %d value%s'
5111 % (nargs, 's' if nargs != 1 else ''))
5112
5113@@ -532,26 +532,26 @@ class TestOption(unittest.TestCase):
5114 env_option.get_value('--%s' % name)
5115
5116 value = env_option.get_value('')
5117- self.assertEquals(value, defaultValue)
5118- self.assertEquals(value.origin, 'default')
5119+ self.assertEqual(value, defaultValue)
5120+ self.assertEqual(value.origin, 'default')
5121
5122 value = env_option.get_value('MOZ_OPTION=', 'environment')
5123- self.assertEquals(value, negOptionValue())
5124- self.assertEquals(value.origin, 'environment')
5125+ self.assertEqual(value, negOptionValue())
5126+ self.assertEqual(value.origin, 'environment')
5127
5128 if nargs in (0, '?', '*'):
5129 value = env_option.get_value('MOZ_OPTION=1', 'environment')
5130- self.assertEquals(value, posOptionValue())
5131+ self.assertEqual(value, posOptionValue())
5132 self.assertTrue(value)
5133- self.assertEquals(value.origin, 'environment')
5134+ self.assertEqual(value.origin, 'environment')
5135 elif nargs in (1, '+'):
5136 value = env_option.get_value('MOZ_OPTION=1', 'environment')
5137- self.assertEquals(value, PositiveOptionValue(('1',)))
5138- self.assertEquals(value.origin, 'environment')
5139+ self.assertEqual(value, PositiveOptionValue(('1',)))
5140+ self.assertEqual(value.origin, 'environment')
5141 else:
5142 with self.assertRaises(InvalidOptionError) as e:
5143 env_option.get_value('MOZ_OPTION=1', 'environment')
5144- self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
5145+ self.assertEqual(e.exception.message, 'MOZ_OPTION takes 2 values')
5146
5147 with self.assertRaises(AssertionError) as e:
5148 env_option.get_value('--%s' % name)
5149@@ -561,26 +561,26 @@ class TestOption(unittest.TestCase):
5150
5151 if nargs in (1, '?', '*', '+'):
5152 value = env_option.get_value('MOZ_OPTION=foo', 'environment')
5153- self.assertEquals(value, PositiveOptionValue(('foo',)))
5154- self.assertEquals(value.origin, 'environment')
5155+ self.assertEqual(value, PositiveOptionValue(('foo',)))
5156+ self.assertEqual(value.origin, 'environment')
5157 else:
5158 with self.assertRaises(InvalidOptionError) as e:
5159 env_option.get_value('MOZ_OPTION=foo', 'environment')
5160- self.assertEquals(e.exception.message,
5161+ self.assertEqual(e.exception.message,
5162 'MOZ_OPTION takes %d values' % nargs)
5163
5164 if nargs in (2, '*', '+'):
5165 value = env_option.get_value('MOZ_OPTION=foo,bar', 'environment')
5166- self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
5167- self.assertEquals(value.origin, 'environment')
5168+ self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
5169+ self.assertEqual(value.origin, 'environment')
5170 else:
5171 with self.assertRaises(InvalidOptionError) as e:
5172 env_option.get_value('MOZ_OPTION=foo,bar', 'environment')
5173 if nargs == '?':
5174- self.assertEquals(e.exception.message,
5175+ self.assertEqual(e.exception.message,
5176 'MOZ_OPTION takes 0 or 1 values')
5177 else:
5178- self.assertEquals(e.exception.message,
5179+ self.assertEqual(e.exception.message,
5180 'MOZ_OPTION takes %d value%s'
5181 % (nargs, 's' if nargs != 1 else ''))
5182
5183@@ -592,28 +592,28 @@ class TestOption(unittest.TestCase):
5184 default=default)
5185
5186 value = option.get_value('--%s-option' % disable, 'option')
5187- self.assertEquals(value, NegativeOptionValue())
5188- self.assertEquals(value.origin, 'option')
5189+ self.assertEqual(value, NegativeOptionValue())
5190+ self.assertEqual(value.origin, 'option')
5191
5192 option = self.test_option_value('%s-option' % disable, nargs=nargs,
5193 default=default)
5194
5195 if nargs in (0, '?', '*'):
5196 value = option.get_value('--%s-option' % enable, 'option')
5197- self.assertEquals(value, PositiveOptionValue())
5198- self.assertEquals(value.origin, 'option')
5199+ self.assertEqual(value, PositiveOptionValue())
5200+ self.assertEqual(value.origin, 'option')
5201 else:
5202 with self.assertRaises(InvalidOptionError) as e:
5203 option.get_value('--%s-option' % enable, 'option')
5204 if nargs == 1:
5205- self.assertEquals(e.exception.message,
5206+ self.assertEqual(e.exception.message,
5207 '--%s-option takes 1 value' % enable)
5208 elif nargs == '+':
5209- self.assertEquals(e.exception.message,
5210+ self.assertEqual(e.exception.message,
5211 '--%s-option takes 1 or more values'
5212 % enable)
5213 else:
5214- self.assertEquals(e.exception.message,
5215+ self.assertEqual(e.exception.message,
5216 '--%s-option takes 2 values' % enable)
5217
5218 def test_option_value_with(self):
5219@@ -622,12 +622,12 @@ class TestOption(unittest.TestCase):
5220 def test_option_value_invalid_nargs(self):
5221 with self.assertRaises(InvalidOptionError) as e:
5222 Option('--option', nargs='foo')
5223- self.assertEquals(e.exception.message,
5224+ self.assertEqual(e.exception.message,
5225 "nargs must be a positive integer, '?', '*' or '+'")
5226
5227 with self.assertRaises(InvalidOptionError) as e:
5228 Option('--option', nargs=-2)
5229- self.assertEquals(e.exception.message,
5230+ self.assertEqual(e.exception.message,
5231 "nargs must be a positive integer, '?', '*' or '+'")
5232
5233 def test_option_value_nargs_1(self):
5234@@ -638,7 +638,7 @@ class TestOption(unittest.TestCase):
5235 # A default is required
5236 with self.assertRaises(InvalidOptionError) as e:
5237 Option('--disable-option', nargs=1)
5238- self.assertEquals(e.exception.message,
5239+ self.assertEqual(e.exception.message,
5240 "The given `default` doesn't satisfy `nargs`")
5241
5242 def test_option_value_nargs_2(self):
5243@@ -649,7 +649,7 @@ class TestOption(unittest.TestCase):
5244 # A default is required
5245 with self.assertRaises(InvalidOptionError) as e:
5246 Option('--disable-option', nargs=2)
5247- self.assertEquals(e.exception.message,
5248+ self.assertEqual(e.exception.message,
5249 "The given `default` doesn't satisfy `nargs`")
5250
5251 def test_option_value_nargs_0_or_1(self):
5252@@ -676,7 +676,7 @@ class TestOption(unittest.TestCase):
5253 # A default is required
5254 with self.assertRaises(InvalidOptionError) as e:
5255 Option('--disable-option', nargs='+')
5256- self.assertEquals(e.exception.message,
5257+ self.assertEqual(e.exception.message,
5258 "The given `default` doesn't satisfy `nargs`")
5259
5260
5261@@ -684,21 +684,21 @@ class TestCommandLineHelper(unittest.TestCase):
5262 def test_basic(self):
5263 helper = CommandLineHelper({}, ['cmd', '--foo', '--bar'])
5264
5265- self.assertEquals(['--foo', '--bar'], list(helper))
5266+ self.assertEqual(['--foo', '--bar'], list(helper))
5267
5268 helper.add('--enable-qux')
5269
5270- self.assertEquals(['--foo', '--bar', '--enable-qux'], list(helper))
5271+ self.assertEqual(['--foo', '--bar', '--enable-qux'], list(helper))
5272
5273 value, option = helper.handle(Option('--bar'))
5274- self.assertEquals(['--foo', '--enable-qux'], list(helper))
5275- self.assertEquals(PositiveOptionValue(), value)
5276- self.assertEquals('--bar', option)
5277+ self.assertEqual(['--foo', '--enable-qux'], list(helper))
5278+ self.assertEqual(PositiveOptionValue(), value)
5279+ self.assertEqual('--bar', option)
5280
5281 value, option = helper.handle(Option('--baz'))
5282- self.assertEquals(['--foo', '--enable-qux'], list(helper))
5283- self.assertEquals(NegativeOptionValue(), value)
5284- self.assertEquals(None, option)
5285+ self.assertEqual(['--foo', '--enable-qux'], list(helper))
5286+ self.assertEqual(NegativeOptionValue(), value)
5287+ self.assertEqual(None, option)
5288
5289 with self.assertRaises(AssertionError):
5290 CommandLineHelper({}, ['--foo', '--bar'])
5291@@ -707,89 +707,89 @@ class TestCommandLineHelper(unittest.TestCase):
5292 foo = Option('--with-foo', nargs='*')
5293 helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b'])
5294 value, option = helper.handle(foo)
5295- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5296- self.assertEquals('command-line', value.origin)
5297- self.assertEquals('--with-foo=a,b', option)
5298+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5299+ self.assertEqual('command-line', value.origin)
5300+ self.assertEqual('--with-foo=a,b', option)
5301
5302 helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b',
5303 '--without-foo'])
5304 value, option = helper.handle(foo)
5305- self.assertEquals(NegativeOptionValue(), value)
5306- self.assertEquals('command-line', value.origin)
5307- self.assertEquals('--without-foo', option)
5308+ self.assertEqual(NegativeOptionValue(), value)
5309+ self.assertEqual('command-line', value.origin)
5310+ self.assertEqual('--without-foo', option)
5311
5312 helper = CommandLineHelper({}, ['cmd', '--without-foo',
5313 '--with-foo=a,b'])
5314 value, option = helper.handle(foo)
5315- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5316- self.assertEquals('command-line', value.origin)
5317- self.assertEquals('--with-foo=a,b', option)
5318+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5319+ self.assertEqual('command-line', value.origin)
5320+ self.assertEqual('--with-foo=a,b', option)
5321
5322 foo = Option('--with-foo', env='FOO', nargs='*')
5323 helper = CommandLineHelper({'FOO': ''}, ['cmd', '--with-foo=a,b'])
5324 value, option = helper.handle(foo)
5325- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5326- self.assertEquals('command-line', value.origin)
5327- self.assertEquals('--with-foo=a,b', option)
5328+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5329+ self.assertEqual('command-line', value.origin)
5330+ self.assertEqual('--with-foo=a,b', option)
5331
5332 helper = CommandLineHelper({'FOO': 'a,b'}, ['cmd', '--without-foo'])
5333 value, option = helper.handle(foo)
5334- self.assertEquals(NegativeOptionValue(), value)
5335- self.assertEquals('command-line', value.origin)
5336- self.assertEquals('--without-foo', option)
5337+ self.assertEqual(NegativeOptionValue(), value)
5338+ self.assertEqual('command-line', value.origin)
5339+ self.assertEqual('--without-foo', option)
5340
5341 helper = CommandLineHelper({'FOO': ''}, ['cmd', '--with-bar=a,b'])
5342 value, option = helper.handle(foo)
5343- self.assertEquals(NegativeOptionValue(), value)
5344- self.assertEquals('environment', value.origin)
5345- self.assertEquals('FOO=', option)
5346+ self.assertEqual(NegativeOptionValue(), value)
5347+ self.assertEqual('environment', value.origin)
5348+ self.assertEqual('FOO=', option)
5349
5350 helper = CommandLineHelper({'FOO': 'a,b'}, ['cmd', '--without-bar'])
5351 value, option = helper.handle(foo)
5352- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5353- self.assertEquals('environment', value.origin)
5354- self.assertEquals('FOO=a,b', option)
5355+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5356+ self.assertEqual('environment', value.origin)
5357+ self.assertEqual('FOO=a,b', option)
5358
5359 helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b', 'FOO='])
5360 value, option = helper.handle(foo)
5361- self.assertEquals(NegativeOptionValue(), value)
5362- self.assertEquals('command-line', value.origin)
5363- self.assertEquals('FOO=', option)
5364+ self.assertEqual(NegativeOptionValue(), value)
5365+ self.assertEqual('command-line', value.origin)
5366+ self.assertEqual('FOO=', option)
5367
5368 helper = CommandLineHelper({}, ['cmd', '--without-foo', 'FOO=a,b'])
5369 value, option = helper.handle(foo)
5370- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5371- self.assertEquals('command-line', value.origin)
5372- self.assertEquals('FOO=a,b', option)
5373+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5374+ self.assertEqual('command-line', value.origin)
5375+ self.assertEqual('FOO=a,b', option)
5376
5377 helper = CommandLineHelper({}, ['cmd', 'FOO=', '--with-foo=a,b'])
5378 value, option = helper.handle(foo)
5379- self.assertEquals(PositiveOptionValue(('a', 'b')), value)
5380- self.assertEquals('command-line', value.origin)
5381- self.assertEquals('--with-foo=a,b', option)
5382+ self.assertEqual(PositiveOptionValue(('a', 'b')), value)
5383+ self.assertEqual('command-line', value.origin)
5384+ self.assertEqual('--with-foo=a,b', option)
5385
5386 helper = CommandLineHelper({}, ['cmd', 'FOO=a,b', '--without-foo'])
5387 value, option = helper.handle(foo)
5388- self.assertEquals(NegativeOptionValue(), value)
5389- self.assertEquals('command-line', value.origin)
5390- self.assertEquals('--without-foo', option)
5391+ self.assertEqual(NegativeOptionValue(), value)
5392+ self.assertEqual('command-line', value.origin)
5393+ self.assertEqual('--without-foo', option)
5394
5395 def test_extra_args(self):
5396 foo = Option('--with-foo', env='FOO', nargs='*')
5397 helper = CommandLineHelper({}, ['cmd'])
5398 helper.add('FOO=a,b,c', 'other-origin')
5399 value, option = helper.handle(foo)
5400- self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
5401- self.assertEquals('other-origin', value.origin)
5402- self.assertEquals('FOO=a,b,c', option)
5403+ self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
5404+ self.assertEqual('other-origin', value.origin)
5405+ self.assertEqual('FOO=a,b,c', option)
5406
5407 helper = CommandLineHelper({}, ['cmd'])
5408 helper.add('FOO=a,b,c', 'other-origin')
5409 helper.add('--with-foo=a,b,c', 'other-origin')
5410 value, option = helper.handle(foo)
5411- self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
5412- self.assertEquals('other-origin', value.origin)
5413- self.assertEquals('--with-foo=a,b,c', option)
5414+ self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
5415+ self.assertEqual('other-origin', value.origin)
5416+ self.assertEqual('--with-foo=a,b,c', option)
5417
5418 # Adding conflicting options is not allowed.
5419 helper = CommandLineHelper({}, ['cmd'])
5420@@ -809,9 +809,9 @@ class TestCommandLineHelper(unittest.TestCase):
5421 # But adding the same is allowed.
5422 helper.add('FOO=a,b,c', 'other-origin')
5423 value, option = helper.handle(foo)
5424- self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
5425- self.assertEquals('other-origin', value.origin)
5426- self.assertEquals('FOO=a,b,c', option)
5427+ self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
5428+ self.assertEqual('other-origin', value.origin)
5429+ self.assertEqual('FOO=a,b,c', option)
5430
5431 # The same rule as above applies when using the option form vs. the
5432 # variable form. But we can't detect it when .add is called.
5433@@ -837,9 +837,9 @@ class TestCommandLineHelper(unittest.TestCase):
5434 helper.add('FOO=a,b,c', 'other-origin')
5435 helper.add('--with-foo=a,b,c', 'other-origin')
5436 value, option = helper.handle(foo)
5437- self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
5438- self.assertEquals('other-origin', value.origin)
5439- self.assertEquals('--with-foo=a,b,c', option)
5440+ self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
5441+ self.assertEqual('other-origin', value.origin)
5442+ self.assertEqual('--with-foo=a,b,c', option)
5443
5444 # Conflicts are also not allowed against what is in the
5445 # environment/on the command line.
5446@@ -869,19 +869,19 @@ class TestCommandLineHelper(unittest.TestCase):
5447 foo = Option('--foo',
5448 possible_origins=('command-line',))
5449 value, option = helper.handle(foo)
5450- self.assertEquals(PositiveOptionValue(), value)
5451- self.assertEquals('command-line', value.origin)
5452- self.assertEquals('--foo', option)
5453+ self.assertEqual(PositiveOptionValue(), value)
5454+ self.assertEqual('command-line', value.origin)
5455+ self.assertEqual('--foo', option)
5456
5457 bar = Option('--bar',
5458 possible_origins=('mozconfig',))
5459- with self.assertRaisesRegexp(InvalidOptionError,
5460+ with self.assertRaisesRegex(InvalidOptionError,
5461 "--bar can not be set by command-line. Values are accepted from: mozconfig"):
5462 helper.handle(bar)
5463
5464 baz = Option(env='BAZ',
5465 possible_origins=('implied',))
5466- with self.assertRaisesRegexp(InvalidOptionError,
5467+ with self.assertRaisesRegex(InvalidOptionError,
5468 "BAZ=1 can not be set by environment. Values are accepted from: implied"):
5469 helper.handle(baz)
5470
5471diff --git a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
5472index cb7ff709e..c339a32bf 100755
5473--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
5474+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
5475@@ -2,12 +2,12 @@
5476 # License, v. 2.0. If a copy of the MPL was not distributed with this
5477 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5478
5479-from __future__ import absolute_import, print_function, unicode_literals
5480+
5481
5482 import logging
5483 import os
5484
5485-from StringIO import StringIO
5486+from io import StringIO
5487
5488 from mozunit import main
5489
5490@@ -366,9 +366,9 @@ class BaseToolchainTest(BaseConfigureTest):
5491 compiler = sandbox._value_for(sandbox[var])
5492 # Add var on both ends to make it clear which of the
5493 # variables is failing the test when that happens.
5494- self.assertEquals((var, compiler), (var, result))
5495+ self.assertEqual((var, compiler), (var, result))
5496 except SystemExit:
5497- self.assertEquals((var, result),
5498+ self.assertEqual((var, result),
5499 (var, self.out.getvalue().strip()))
5500 return
5501
5502@@ -407,7 +407,7 @@ class BaseToolchainTest(BaseConfigureTest):
5503 'RUST_LIB_SUFFIX',
5504 'OBJ_SUFFIX',
5505 ):
5506- self.assertEquals('%s=%s' % (k, sandbox.get_config(k)),
5507+ self.assertEqual('%s=%s' % (k, sandbox.get_config(k)),
5508 '%s=%s' % (k, library_name_info[k]))
5509
5510
5511@@ -584,7 +584,7 @@ class LinuxToolchainTest(BaseToolchainTest):
5512 # We'll try gcc and clang, but since there is no gcc (gcc-x.y doesn't
5513 # count), find clang.
5514 paths = {
5515- k: v for k, v in self.PATHS.iteritems()
5516+ k: v for k, v in self.PATHS.items()
5517 if os.path.basename(k) not in ('gcc', 'g++')
5518 }
5519 self.do_toolchain_test(paths, {
5520@@ -619,7 +619,7 @@ class LinuxToolchainTest(BaseToolchainTest):
5521 # Even if there are gcc-x.y or clang-x.y compilers available, we
5522 # don't try them. This could be considered something to improve.
5523 paths = {
5524- k: v for k, v in self.PATHS.iteritems()
5525+ k: v for k, v in self.PATHS.items()
5526 if os.path.basename(k) not in ('gcc', 'g++', 'clang', 'clang++')
5527 }
5528 self.do_toolchain_test(paths, {
5529@@ -800,7 +800,7 @@ class OSXToolchainTest(BaseToolchainTest):
5530 def test_not_gcc(self):
5531 # We won't pick GCC if it's the only thing available.
5532 paths = {
5533- k: v for k, v in self.PATHS.iteritems()
5534+ k: v for k, v in self.PATHS.items()
5535 if os.path.basename(k) not in ('clang', 'clang++')
5536 }
5537 self.do_toolchain_test(paths, {
5538@@ -976,7 +976,7 @@ class WindowsToolchainTest(BaseToolchainTest):
5539 def test_clang_cl(self):
5540 # We'll pick clang-cl if msvc can't be found.
5541 paths = {
5542- k: v for k, v in self.PATHS.iteritems()
5543+ k: v for k, v in self.PATHS.items()
5544 if os.path.basename(k) != 'cl'
5545 }
5546 self.do_toolchain_test(paths, {
5547@@ -987,7 +987,7 @@ class WindowsToolchainTest(BaseToolchainTest):
5548 def test_gcc(self):
5549 # We'll pick GCC if msvc and clang-cl can't be found.
5550 paths = {
5551- k: v for k, v in self.PATHS.iteritems()
5552+ k: v for k, v in self.PATHS.items()
5553 if os.path.basename(k) not in ('cl', 'clang-cl')
5554 }
5555 self.do_toolchain_test(paths, {
5556@@ -1006,7 +1006,7 @@ class WindowsToolchainTest(BaseToolchainTest):
5557 def test_clang(self):
5558 # We'll pick clang if nothing else is found.
5559 paths = {
5560- k: v for k, v in self.PATHS.iteritems()
5561+ k: v for k, v in self.PATHS.items()
5562 if os.path.basename(k) not in ('cl', 'clang-cl', 'gcc')
5563 }
5564 self.do_toolchain_test(paths, {
5565diff --git a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
5566index 8ec33a8b7..ba046ed12 100644
5567--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
5568+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
5569@@ -2,7 +2,7 @@
5570 # License, v. 2.0. If a copy of the MPL was not distributed with this
5571 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5572
5573-from __future__ import absolute_import, print_function, unicode_literals
5574+
5575
5576 import copy
5577 import re
5578@@ -10,7 +10,7 @@ import types
5579 import unittest
5580
5581 from fnmatch import fnmatch
5582-from StringIO import StringIO
5583+from io import StringIO
5584 from textwrap import dedent
5585
5586 from mozunit import (
5587@@ -43,7 +43,7 @@ class CompilerPreprocessor(Preprocessor):
5588 # Hack around it enough that the configure tests work properly.
5589 context = self.context
5590 def normalize_numbers(value):
5591- if isinstance(value, types.StringTypes):
5592+ if isinstance(value, (str,)):
5593 if value[-1:] == 'L' and value[:-1].isdigit():
5594 value = int(value[:-1])
5595 return value
5596@@ -53,7 +53,7 @@ class CompilerPreprocessor(Preprocessor):
5597 return self.HAS_FEATURE.sub(r'\1\2', expr)
5598 self.context = self.Context(
5599 (normalize_has_feature(k), normalize_numbers(v))
5600- for k, v in context.iteritems()
5601+ for k, v in context.items()
5602 )
5603 try:
5604 return Preprocessor.do_if(self, normalize_has_feature(expression),
5605@@ -95,7 +95,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
5606 input.name = 'foo'
5607 pp.do_include(input)
5608
5609- self.assertEquals(pp.out.getvalue(), '1 . 2 . c "D"')
5610+ self.assertEqual(pp.out.getvalue(), '1 . 2 . c "D"')
5611
5612 def test_condition(self):
5613 pp = CompilerPreprocessor({
5614@@ -125,7 +125,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
5615 input.name = 'foo'
5616 pp.do_include(input)
5617
5618- self.assertEquals('IFDEF_A\nIF_A\nIF_B\nIF_NOT_C\n', pp.out.getvalue())
5619+ self.assertEqual('IFDEF_A\nIF_A\nIF_B\nIF_NOT_C\n', pp.out.getvalue())
5620
5621
5622 class FakeCompiler(dict):
5623@@ -164,9 +164,9 @@ class FakeCompiler(dict):
5624 '''
5625 def __init__(self, *definitions):
5626 for definition in definitions:
5627- if all(not isinstance(d, dict) for d in definition.itervalues()):
5628+ if all(not isinstance(d, dict) for d in definition.values()):
5629 definition = {None: definition}
5630- for key, value in definition.iteritems():
5631+ for key, value in definition.items():
5632 self.setdefault(key, {}).update(value)
5633
5634 def __call__(self, stdin, args):
5635@@ -178,14 +178,14 @@ class FakeCompiler(dict):
5636 pp = CompilerPreprocessor(self[None])
5637
5638 def apply_defn(defn):
5639- for k, v in defn.iteritems():
5640+ for k, v in defn.items():
5641 if v is False:
5642 if k in pp.context:
5643 del pp.context[k]
5644 else:
5645 pp.context[k] = v
5646
5647- for glob, defn in self.iteritems():
5648+ for glob, defn in self.items():
5649 if glob and not glob.startswith('-') and fnmatch(file, glob):
5650 apply_defn(defn)
5651
5652@@ -216,7 +216,7 @@ class TestFakeCompiler(unittest.TestCase):
5653 'A': '1',
5654 'B': '2',
5655 })
5656- self.assertEquals(compiler(None, ['-E', 'file']),
5657+ self.assertEqual(compiler(None, ['-E', 'file']),
5658 (0, '1 2 C', ''))
5659
5660 compiler = FakeCompiler({
5661@@ -238,25 +238,25 @@ class TestFakeCompiler(unittest.TestCase):
5662 'B': '42',
5663 },
5664 })
5665- self.assertEquals(compiler(None, ['-E', 'file']),
5666+ self.assertEqual(compiler(None, ['-E', 'file']),
5667 (0, '1 2 C', ''))
5668- self.assertEquals(compiler(None, ['-E', '-foo', 'file']),
5669+ self.assertEqual(compiler(None, ['-E', '-foo', 'file']),
5670 (0, '1 2 foo', ''))
5671- self.assertEquals(compiler(None, ['-E', '-bar', 'file']),
5672+ self.assertEqual(compiler(None, ['-E', '-bar', 'file']),
5673 (0, '1 bar bar', ''))
5674- self.assertEquals(compiler(None, ['-E', '-qux', 'file']),
5675+ self.assertEqual(compiler(None, ['-E', '-qux', 'file']),
5676 (0, '1 B C', ''))
5677- self.assertEquals(compiler(None, ['-E', '-foo', '-bar', 'file']),
5678+ self.assertEqual(compiler(None, ['-E', '-foo', '-bar', 'file']),
5679 (0, '1 bar bar', ''))
5680- self.assertEquals(compiler(None, ['-E', '-bar', '-foo', 'file']),
5681+ self.assertEqual(compiler(None, ['-E', '-bar', '-foo', 'file']),
5682 (0, '1 bar foo', ''))
5683- self.assertEquals(compiler(None, ['-E', '-bar', '-qux', 'file']),
5684+ self.assertEqual(compiler(None, ['-E', '-bar', '-qux', 'file']),
5685 (0, '1 B bar', ''))
5686- self.assertEquals(compiler(None, ['-E', '-qux', '-bar', 'file']),
5687+ self.assertEqual(compiler(None, ['-E', '-qux', '-bar', 'file']),
5688 (0, '1 bar bar', ''))
5689- self.assertEquals(compiler(None, ['-E', 'file.c']),
5690+ self.assertEqual(compiler(None, ['-E', 'file.c']),
5691 (0, '1 42 C', ''))
5692- self.assertEquals(compiler(None, ['-E', '-bar', 'file.c']),
5693+ self.assertEqual(compiler(None, ['-E', '-bar', 'file.c']),
5694 (0, '1 bar bar', ''))
5695
5696 def test_multiple_definitions(self):
5697@@ -267,7 +267,7 @@ class TestFakeCompiler(unittest.TestCase):
5698 'C': 3,
5699 })
5700
5701- self.assertEquals(compiler, {
5702+ self.assertEqual(compiler, {
5703 None: {
5704 'A': 1,
5705 'B': 2,
5706@@ -282,7 +282,7 @@ class TestFakeCompiler(unittest.TestCase):
5707 'C': 3,
5708 })
5709
5710- self.assertEquals(compiler, {
5711+ self.assertEqual(compiler, {
5712 None: {
5713 'A': 1,
5714 'B': 4,
5715@@ -302,7 +302,7 @@ class TestFakeCompiler(unittest.TestCase):
5716 },
5717 })
5718
5719- self.assertEquals(compiler, {
5720+ self.assertEqual(compiler, {
5721 None: {
5722 'A': 1,
5723 'B': 4,
5724@@ -330,7 +330,7 @@ class TestFakeCompiler(unittest.TestCase):
5725 },
5726 })
5727
5728- self.assertEquals(compiler, {
5729+ self.assertEqual(compiler, {
5730 None: {
5731 'A': 1,
5732 'B': 2,
5733@@ -370,7 +370,7 @@ class CompilerResult(ReadOnlyNamespace):
5734 def __add__(self, other):
5735 assert isinstance(other, dict)
5736 result = copy.deepcopy(self.__dict__)
5737- for k, v in other.iteritems():
5738+ for k, v in other.items():
5739 if k == 'flags':
5740 result.setdefault(k, []).extend(v)
5741 else:
5742@@ -381,7 +381,7 @@ class CompilerResult(ReadOnlyNamespace):
5743 class TestCompilerResult(unittest.TestCase):
5744 def test_compiler_result(self):
5745 result = CompilerResult()
5746- self.assertEquals(result.__dict__, {
5747+ self.assertEqual(result.__dict__, {
5748 'wrapper': [],
5749 'compiler': mozpath.abspath(''),
5750 'version': '',
5751@@ -397,7 +397,7 @@ class TestCompilerResult(unittest.TestCase):
5752 language='C',
5753 flags=['-std=gnu99'],
5754 )
5755- self.assertEquals(result.__dict__, {
5756+ self.assertEqual(result.__dict__, {
5757 'wrapper': [],
5758 'compiler': mozpath.abspath('/usr/bin/gcc'),
5759 'version': '4.2.1',
5760@@ -407,7 +407,7 @@ class TestCompilerResult(unittest.TestCase):
5761 })
5762
5763 result2 = result + {'flags': ['-m32']}
5764- self.assertEquals(result2.__dict__, {
5765+ self.assertEqual(result2.__dict__, {
5766 'wrapper': [],
5767 'compiler': mozpath.abspath('/usr/bin/gcc'),
5768 'version': '4.2.1',
5769@@ -416,14 +416,14 @@ class TestCompilerResult(unittest.TestCase):
5770 'flags': ['-std=gnu99', '-m32'],
5771 })
5772 # Original flags are untouched.
5773- self.assertEquals(result.flags, ['-std=gnu99'])
5774+ self.assertEqual(result.flags, ['-std=gnu99'])
5775
5776 result3 = result + {
5777 'compiler': '/usr/bin/gcc-4.7',
5778 'version': '4.7.3',
5779 'flags': ['-m32'],
5780 }
5781- self.assertEquals(result3.__dict__, {
5782+ self.assertEqual(result3.__dict__, {
5783 'wrapper': [],
5784 'compiler': mozpath.abspath('/usr/bin/gcc-4.7'),
5785 'version': '4.7.3',
5786diff --git a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
5787index ac35d745f..cdd8ece1b 100644
5788--- a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
5789+++ b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py
5790@@ -2,7 +2,7 @@
5791 # License, v. 2.0. If a copy of the MPL was not distributed with this
5792 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5793
5794-from __future__ import absolute_import, print_function, unicode_literals
5795+
5796
5797 import os
5798
5799diff --git a/python/mozbuild/mozbuild/test/configure/test_util.py b/python/mozbuild/mozbuild/test/configure/test_util.py
5800index 9f9575fd0..c2db1a628 100644
5801--- a/python/mozbuild/mozbuild/test/configure/test_util.py
5802+++ b/python/mozbuild/mozbuild/test/configure/test_util.py
5803@@ -2,7 +2,7 @@
5804 # License, v. 2.0. If a copy of the MPL was not distributed with this
5805 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5806
5807-from __future__ import absolute_import, print_function, unicode_literals
5808+
5809
5810 import logging
5811 import os
5812@@ -11,7 +11,7 @@ import textwrap
5813 import unittest
5814 import sys
5815
5816-from StringIO import StringIO
5817+from io import StringIO
5818
5819 from mozunit import main
5820 from mozpack import path as mozpath
5821@@ -434,11 +434,11 @@ class TestLogSubprocessOutput(unittest.TestCase):
5822 except SystemExit as e:
5823 status = e.code
5824
5825- self.assertEquals(status, 0)
5826+ self.assertEqual(status, 0)
5827 quote_char = "'"
5828 if getpreferredencoding().lower() == 'utf-8':
5829 quote_char = '\u00B4'.encode('utf-8')
5830- self.assertEquals(out.getvalue().strip(), quote_char)
5831+ self.assertEqual(out.getvalue().strip(), quote_char)
5832
5833
5834 class TestVersion(unittest.TestCase):
5835diff --git a/python/mozbuild/mozbuild/testing.py b/python/mozbuild/mozbuild/testing.py
5836index 3229c3f77..82d250fab 100644
5837--- a/python/mozbuild/mozbuild/testing.py
5838+++ b/python/mozbuild/mozbuild/testing.py
5839@@ -2,9 +2,9 @@
5840 # License, v. 2.0. If a copy of the MPL was not distributed with this
5841 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5842
5843-from __future__ import absolute_import, unicode_literals
5844
5845-import cPickle as pickle
5846+
5847+import pickle as pickle
5848 import os
5849 import sys
5850
5851@@ -70,7 +70,7 @@ REFTEST_FLAVORS = ('crashtest', 'reftest')
5852 WEB_PLATFORM_TESTS_FLAVORS = ('web-platform-tests',)
5853
5854 def all_test_flavors():
5855- return ([v[0] for v in TEST_MANIFESTS.values()] +
5856+ return ([v[0] for v in list(TEST_MANIFESTS.values())] +
5857 list(REFTEST_FLAVORS) +
5858 list(WEB_PLATFORM_TESTS_FLAVORS))
5859
5860@@ -210,7 +210,7 @@ def install_test_files(topsrcdir, topobjdir, tests_root, test_objs):
5861 only a few tests need to be run.
5862 """
5863 flavor_info = {flavor: (root, prefix, install)
5864- for (flavor, root, prefix, install) in TEST_MANIFESTS.values()}
5865+ for (flavor, root, prefix, install) in list(TEST_MANIFESTS.values())}
5866 objdir_dest = mozpath.join(topobjdir, tests_root)
5867
5868 converter = SupportFilesConverter()
5869@@ -292,7 +292,7 @@ def read_wpt_manifest(context, paths):
5870 paths_file = os.path.join(context.config.topsrcdir, "testing",
5871 "web-platform", "tests", "tools", "localpaths.py")
5872 _globals = {"__file__": paths_file}
5873- execfile(paths_file, _globals)
5874+ exec(compile(open(paths_file, "rb").read(), paths_file, 'exec'), _globals)
5875 import manifest as wptmanifest
5876 finally:
5877 sys.path = old_path
5878diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
5879index 4ea227dc0..79cb15713 100644
5880--- a/python/mozbuild/mozbuild/util.py
5881+++ b/python/mozbuild/mozbuild/util.py
5882@@ -5,7 +5,7 @@
5883 # This file contains miscellaneous utility functions that don't belong anywhere
5884 # in particular.
5885
5886-from __future__ import absolute_import, unicode_literals, print_function
5887+
5888
5889 import argparse
5890 import collections
5891@@ -21,6 +21,9 @@ import stat
5892 import sys
5893 import time
5894 import types
5895+import pprint
5896+import six
5897+import subprocess
5898
5899 from collections import (
5900 defaultdict,
5901@@ -36,7 +39,7 @@ from io import (
5902 if sys.version_info[0] == 3:
5903 str_type = str
5904 else:
5905- str_type = basestring
5906+ str_type = str
5907
5908 if sys.platform == 'win32':
5909 _kernel32 = ctypes.windll.kernel32
5910@@ -78,7 +81,7 @@ def hash_file(path, hasher=None):
5911 return h.hexdigest()
5912
5913
5914-class EmptyValue(unicode):
5915+class EmptyValue(str):
5916 """A dummy type that behaves like an empty string and sequence.
5917
5918 This type exists in order to support
5919@@ -92,7 +95,7 @@ class EmptyValue(unicode):
5920 class ReadOnlyNamespace(object):
5921 """A class for objects with immutable attributes set at initialization."""
5922 def __init__(self, **kwargs):
5923- for k, v in kwargs.iteritems():
5924+ for k, v in kwargs.items():
5925 super(ReadOnlyNamespace, self).__setattr__(k, v)
5926
5927 def __delattr__(self, key):
5928@@ -224,7 +227,7 @@ class FileAvoidWrite(BytesIO):
5929 self.mode = mode
5930
5931 def write(self, buf):
5932- if isinstance(buf, unicode):
5933+ if isinstance(buf, str):
5934 buf = buf.encode('utf-8')
5935 BytesIO.write(self, buf)
5936
5937@@ -267,6 +270,10 @@ class FileAvoidWrite(BytesIO):
5938 if 'b' in self.mode:
5939 writemode += 'b'
5940 with open(self.name, writemode) as file:
5941+ if 'b' in self.mode and isinstance(buf, str):
5942+ buf = buf.encode('utf-8')
5943+ elif 'b' not in self.mode and isinstance(buf, bytes):
5944+ buf = buf.decode('utf-8')
5945 file.write(buf)
5946
5947 if self._capture_diff:
5948@@ -381,7 +388,7 @@ class ListMixin(object):
5949 def __add__(self, other):
5950 # Allow None and EmptyValue is a special case because it makes undefined
5951 # variable references in moz.build behave better.
5952- other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
5953+ other = [] if isinstance(other, (type(None), EmptyValue)) else other
5954 if not isinstance(other, list):
5955 raise ValueError('Only lists can be appended to lists.')
5956
5957@@ -390,7 +397,7 @@ class ListMixin(object):
5958 return new_list
5959
5960 def __iadd__(self, other):
5961- other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
5962+ other = [] if isinstance(other, (type(None), EmptyValue)) else other
5963 if not isinstance(other, list):
5964 raise ValueError('Only lists can be appended to lists.')
5965
5966@@ -561,14 +568,14 @@ def FlagsFactory(flags):
5967 functions below.
5968 """
5969 assert isinstance(flags, dict)
5970- assert all(isinstance(v, type) for v in flags.values())
5971+ assert all(isinstance(v, type) for v in list(flags.values()))
5972
5973 class Flags(object):
5974- __slots__ = flags.keys()
5975+ __slots__ = list(flags.keys())
5976 _flags = flags
5977
5978 def update(self, **kwargs):
5979- for k, v in kwargs.iteritems():
5980+ for k, v in kwargs.items():
5981 setattr(self, k, v)
5982
5983 def __getattr__(self, name):
5984@@ -1006,8 +1013,6 @@ def TypedNamedTuple(name, fields):
5985 'got %s, expected %s' % (fname,
5986 type(value), ftype))
5987
5988- super(TypedTuple, self).__init__(*args, **kwargs)
5989-
5990 TypedTuple._fields = fields
5991
5992 return TypedTuple
5993@@ -1099,14 +1104,14 @@ def group_unified_files(files, unified_prefix, unified_suffix,
5994 # issue. So we do a little dance to filter it out ourselves.
5995 dummy_fill_value = ("dummy",)
5996 def filter_out_dummy(iterable):
5997- return itertools.ifilter(lambda x: x != dummy_fill_value,
5998+ return filter(lambda x: x != dummy_fill_value,
5999 iterable)
6000
6001 # From the itertools documentation, slightly modified:
6002 def grouper(n, iterable):
6003 "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
6004 args = [iter(iterable)] * n
6005- return itertools.izip_longest(fillvalue=dummy_fill_value, *args)
6006+ return itertools.zip_longest(fillvalue=dummy_fill_value, *args)
6007
6008 for i, unified_group in enumerate(grouper(files_per_unified_file,
6009 files)):
6010@@ -1123,7 +1128,7 @@ def pair(iterable):
6011 [(1,2), (3,4), (5,6)]
6012 '''
6013 i = iter(iterable)
6014- return itertools.izip_longest(i, i)
6015+ return itertools.zip_longest(i, i)
6016
6017
6018 VARIABLES_RE = re.compile('\$\((\w+)\)')
6019@@ -1141,7 +1146,7 @@ def expand_variables(s, variables):
6020 value = variables.get(name)
6021 if not value:
6022 continue
6023- if not isinstance(value, types.StringTypes):
6024+ if not isinstance(value, (str,)):
6025 value = ' '.join(value)
6026 result += value
6027 return result
6028@@ -1168,7 +1173,7 @@ class EnumStringComparisonError(Exception):
6029 pass
6030
6031
6032-class EnumString(unicode):
6033+class EnumString(str):
6034 '''A string type that only can have a limited set of values, similarly to
6035 an Enum, and can only be compared against that set of values.
6036
6037@@ -1185,8 +1190,8 @@ class EnumString(unicode):
6038 def __eq__(self, other):
6039 if other not in self.POSSIBLE_VALUES:
6040 raise EnumStringComparisonError(
6041- 'Can only compare with %s'
6042- % ', '.join("'%s'" % v for v in self.POSSIBLE_VALUES))
6043+ '%s is not in %s'
6044+ % (other, ', '.join("'%s'" % v for v in self.POSSIBLE_VALUES)))
6045 return super(EnumString, self).__eq__(other)
6046
6047 def __ne__(self, other):
6048@@ -1204,14 +1209,14 @@ def _escape_char(c):
6049 # quoting could be done with either ' or ".
6050 if c == "'":
6051 return "\\'"
6052- return unicode(c.encode('unicode_escape'))
6053+ return str(c.encode('unicode_escape'))
6054
6055 # Mapping table between raw characters below \x80 and their escaped
6056 # counterpart, when they differ
6057 _INDENTED_REPR_TABLE = {
6058 c: e
6059 for c, e in map(lambda x: (x, _escape_char(x)),
6060- map(unichr, range(128)))
6061+ map(chr, range(128)))
6062 if c != e
6063 }
6064 # Regexp matching all characters to escape.
6065@@ -1219,7 +1224,33 @@ _INDENTED_REPR_RE = re.compile(
6066 '([' + ''.join(_INDENTED_REPR_TABLE.values()) + ']+)')
6067
6068
6069+# Stolen from gecko master [1]
6070+# [1] https://github.com/mozilla/gecko-dev/blob/4165a2e843c494bfb3e35d8a1fbf9c61209e3675/python/mozbuild/mozbuild/util.py#L1286
6071+
6072+# The default PrettyPrinter has some issues with UTF-8, so we need to override
6073+# some stuff here.
6074+class _PrettyPrinter(pprint.PrettyPrinter):
6075+ def format(self, object, context, maxlevels, level):
6076+ if not (isinstance(object, six.text_type) or
6077+ isinstance(object, six.binary_type)):
6078+ return super(_PrettyPrinter, self).format(
6079+ object, context, maxlevels, level)
6080+ # This is super hacky and weird, but the output of 'repr' actually
6081+ # varies based on the default I/O encoding of the process, which isn't
6082+ # necessarily utf-8. Instead we open a new shell and ask what the repr
6083+ # WOULD be assuming the default encoding is utf-8. If you can come up
6084+ # with a better way of doing this without simply re-implementing the
6085+ # logic of "repr", please replace this.
6086+ env = dict(os.environ)
6087+ env['PYTHONIOENCODING'] = 'utf-8'
6088+ ret = six.ensure_text(subprocess.check_output(
6089+ [sys.executable], input='print(repr(%s))' % repr(object),
6090+ universal_newlines=True, env=env, encoding='utf-8')).strip()
6091+ return (ret, True, False)
6092+
6093 def indented_repr(o, indent=4):
6094+ return _PrettyPrinter(indent=indent).pformat(o)
6095+
6096 '''Similar to repr(), but returns an indented representation of the object
6097
6098 One notable difference with repr is that the returned representation
6099@@ -1242,7 +1273,7 @@ def indented_repr(o, indent=4):
6100 elif isinstance(o, bytes):
6101 yield 'b'
6102 yield repr(o)
6103- elif isinstance(o, unicode):
6104+ elif isinstance(o, str):
6105 yield "'"
6106 # We want a readable string (non escaped unicode), but some
6107 # special characters need escaping (e.g. \n, \t, etc.)
6108@@ -1272,11 +1303,11 @@ def encode(obj, encoding='utf-8'):
6109 if isinstance(obj, dict):
6110 return {
6111 encode(k, encoding): encode(v, encoding)
6112- for k, v in obj.iteritems()
6113+ for k, v in obj.items()
6114 }
6115 if isinstance(obj, bytes):
6116 return obj
6117- if isinstance(obj, unicode):
6118+ if isinstance(obj, str):
6119 return obj.encode(encoding)
6120 if isinstance(obj, Iterable):
6121 return [encode(i, encoding) for i in obj]
6122diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.py
6123index 38d06d71d..c67c046f3 100644
6124--- a/python/mozbuild/mozbuild/virtualenv.py
6125+++ b/python/mozbuild/mozbuild/virtualenv.py
6126@@ -531,9 +531,9 @@ def verify_python_version(log_handle):
6127
6128 our = LooseVersion('%d.%d.%d' % (major, minor, micro))
6129
6130- if major != MINIMUM_PYTHON_MAJOR or our < MINIMUM_PYTHON_VERSION:
6131- log_handle.write('Python %s or greater (but not Python 3) is '
6132- 'required to build. ' % MINIMUM_PYTHON_VERSION)
6133+ if our < MINIMUM_PYTHON_VERSION:
6134+ log_handle.write('Python %s or greater is required to build. '
6135+ % MINIMUM_PYTHON_VERSION)
6136 log_handle.write('You are running Python %s.\n' % our)
6137
6138 if os.name in ('nt', 'ce'):
6139diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py
6140index c91b99cf1..02eac0dbb 100644
6141--- a/python/mozbuild/mozpack/chrome/manifest.py
6142+++ b/python/mozbuild/mozpack/chrome/manifest.py
6143@@ -2,11 +2,11 @@
6144 # License, v. 2.0. If a copy of the MPL was not distributed with this
6145 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6146
6147-from __future__ import absolute_import
6148+
6149
6150 import re
6151 import os
6152-from urlparse import urlparse
6153+from urllib.parse import urlparse
6154 import mozpack.path as mozpath
6155 from mozpack.chrome.flags import Flags
6156 from mozpack.errors import errors
6157@@ -316,7 +316,7 @@ class ManifestContract(ManifestEntry):
6158 return self.serialize(self.contractID, self.cid)
6159
6160 # All manifest classes by their type name.
6161-MANIFESTS_TYPES = dict([(c.type, c) for c in globals().values()
6162+MANIFESTS_TYPES = dict([(c.type, c) for c in list(globals().values())
6163 if type(c) == type and issubclass(c, ManifestEntry)
6164 and hasattr(c, 'type') and c.type])
6165
6166diff --git a/python/mozbuild/mozpack/copier.py b/python/mozbuild/mozpack/copier.py
6167index 1e521e52b..43ed9be4a 100644
6168--- a/python/mozbuild/mozpack/copier.py
6169+++ b/python/mozbuild/mozpack/copier.py
6170@@ -2,7 +2,7 @@
6171 # License, v. 2.0. If a copy of the MPL was not distributed with this
6172 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6173
6174-from __future__ import absolute_import
6175+
6176
6177 import os
6178 import stat
6179@@ -113,7 +113,7 @@ class FileRegistry(object):
6180 '''
6181 Return all paths stored in the container, in the order they were added.
6182 '''
6183- return self._files.keys()
6184+ return list(self._files.keys())
6185
6186 def __len__(self):
6187 '''
6188@@ -146,7 +146,7 @@ class FileRegistry(object):
6189 for path, file in registry:
6190 (...)
6191 '''
6192- return self._files.iteritems()
6193+ return iter(self._files.items())
6194
6195 def required_directories(self):
6196 '''
6197@@ -155,7 +155,7 @@ class FileRegistry(object):
6198 unspecified (virtual) root directory (and do not include said root
6199 directory).
6200 '''
6201- return set(k for k, v in self._required_directories.items() if v > 0)
6202+ return set(k for k, v in list(self._required_directories.items()) if v > 0)
6203
6204 def output_to_inputs_tree(self):
6205 '''
6206@@ -295,7 +295,7 @@ class FileCopier(FileRegistry):
6207
6208 Returns a FileCopyResult that details what changed.
6209 '''
6210- assert isinstance(destination, basestring)
6211+ assert isinstance(destination, str)
6212 assert not os.path.exists(destination) or os.path.isdir(destination)
6213
6214 result = FileCopyResult()
6215@@ -563,7 +563,7 @@ class Jarrer(FileRegistry, BaseFile):
6216 def exists(self):
6217 return self.deflater is not None
6218
6219- if isinstance(dest, basestring):
6220+ if isinstance(dest, str):
6221 dest = Dest(dest)
6222 assert isinstance(dest, Dest)
6223
6224diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py
6225index 8ce353375..bf35e39b8 100644
6226--- a/python/mozbuild/mozpack/files.py
6227+++ b/python/mozbuild/mozpack/files.py
6228@@ -2,7 +2,7 @@
6229 # License, v. 2.0. If a copy of the MPL was not distributed with this
6230 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6231
6232-from __future__ import absolute_import
6233+
6234
6235 import errno
6236 import os
6237@@ -57,7 +57,7 @@ else:
6238
6239 def _copyfile(src, dest):
6240 # False indicates `dest` should be overwritten if it exists already.
6241- if isinstance(src, unicode) and isinstance(dest, unicode):
6242+ if isinstance(src, str) and isinstance(dest, str):
6243 _CopyFileW(src, dest, False)
6244 elif isinstance(src, str) and isinstance(dest, str):
6245 _CopyFileA(src, dest, False)
6246@@ -164,7 +164,7 @@ class BaseFile(object):
6247 disabled when skip_if_older is False.
6248 Returns whether a copy was actually performed (True) or not (False).
6249 '''
6250- if isinstance(dest, basestring):
6251+ if isinstance(dest, str):
6252 dest = Dest(dest)
6253 else:
6254 assert isinstance(dest, Dest)
6255@@ -278,11 +278,11 @@ class ExecutableFile(File):
6256 '''
6257 def copy(self, dest, skip_if_older=True):
6258 real_dest = dest
6259- if not isinstance(dest, basestring):
6260+ if not isinstance(dest, str):
6261 fd, dest = mkstemp()
6262 os.close(fd)
6263 os.remove(dest)
6264- assert isinstance(dest, basestring)
6265+ assert isinstance(dest, str)
6266 # If File.copy didn't actually copy because dest is newer, check the
6267 # file sizes. If dest is smaller, it means it is already stripped and
6268 # elfhacked, so we can skip.
6269@@ -319,7 +319,7 @@ class AbsoluteSymlinkFile(File):
6270 File.__init__(self, path)
6271
6272 def copy(self, dest, skip_if_older=True):
6273- assert isinstance(dest, basestring)
6274+ assert isinstance(dest, str)
6275
6276 # The logic in this function is complicated by the fact that symlinks
6277 # aren't universally supported. So, where symlinks aren't supported, we
6278@@ -410,7 +410,7 @@ class HardlinkFile(File):
6279 '''
6280
6281 def copy(self, dest, skip_if_older=True):
6282- assert isinstance(dest, basestring)
6283+ assert isinstance(dest, str)
6284
6285 if not hasattr(os, 'link'):
6286 return super(HardlinkFile, self).copy(
6287@@ -471,7 +471,7 @@ class ExistingFile(BaseFile):
6288 self.required = required
6289
6290 def copy(self, dest, skip_if_older=True):
6291- if isinstance(dest, basestring):
6292+ if isinstance(dest, str):
6293 dest = Dest(dest)
6294 else:
6295 assert isinstance(dest, Dest)
6296@@ -517,7 +517,7 @@ class PreprocessedFile(BaseFile):
6297 '''
6298 Invokes the preprocessor to create the destination file.
6299 '''
6300- if isinstance(dest, basestring):
6301+ if isinstance(dest, str):
6302 dest = Dest(dest)
6303 else:
6304 assert isinstance(dest, Dest)
6305@@ -657,7 +657,7 @@ class XPTFile(GeneratedFile):
6306 the individual XPTs to link.
6307 skip_if_older is ignored.
6308 '''
6309- if isinstance(dest, basestring):
6310+ if isinstance(dest, str):
6311 dest = Dest(dest)
6312 assert isinstance(dest, Dest)
6313
6314@@ -1108,7 +1108,7 @@ class ComposedFinder(BaseFinder):
6315 from mozpack.copier import FileRegistry
6316 self.files = FileRegistry()
6317
6318- for base, finder in sorted(finders.iteritems()):
6319+ for base, finder in sorted(finders.items()):
6320 if self.files.contains(base):
6321 self.files.remove(base)
6322 for p, f in finder.find(''):
6323diff --git a/python/mozbuild/mozpack/manifests.py b/python/mozbuild/mozpack/manifests.py
6324index 27c66634b..f79b40086 100644
6325--- a/python/mozbuild/mozpack/manifests.py
6326+++ b/python/mozbuild/mozpack/manifests.py
6327@@ -2,8 +2,6 @@
6328 # License, v. 2.0. If a copy of the MPL was not distributed with this
6329 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6330
6331-from __future__ import absolute_import, unicode_literals
6332-
6333 from contextlib import contextmanager
6334 import json
6335
6336@@ -116,7 +114,7 @@ class InstallManifest(object):
6337 self._source_files = set()
6338
6339 if path or fileobj:
6340- with _auto_fileobj(path, fileobj, 'rb') as fh:
6341+ with _auto_fileobj(path, fileobj, 'r') as fh:
6342 self._source_files.add(fh.name)
6343 self._load_from_fileobj(fh)
6344
6345@@ -175,7 +173,7 @@ class InstallManifest(object):
6346 dest, content = fields[1:]
6347
6348 self.add_content(
6349- self._decode_field_entry(content).encode('utf-8'), dest)
6350+ self._decode_field_entry(content), dest)
6351 continue
6352
6353 # Don't fail for non-actionable items, allowing
6354@@ -228,7 +226,7 @@ class InstallManifest(object):
6355
6356 It is an error if both are specified.
6357 """
6358- with _auto_fileobj(path, fileobj, 'wb') as fh:
6359+ with _auto_fileobj(path, fileobj, 'w') as fh:
6360 fh.write('%d\n' % self.CURRENT_VERSION)
6361
6362 for dest in sorted(self._dests):
6363@@ -242,13 +240,11 @@ class InstallManifest(object):
6364 for path in paths:
6365 source = mozpath.join(base, path)
6366 parts = ['%d' % type, mozpath.join(dest, path), source]
6367- fh.write('%s\n' % self.FIELD_SEPARATOR.join(
6368- p.encode('utf-8') for p in parts))
6369+ fh.write('%s\n' % self.FIELD_SEPARATOR.join(parts))
6370 else:
6371 parts = ['%d' % entry[0], dest]
6372 parts.extend(entry[1:])
6373- fh.write('%s\n' % self.FIELD_SEPARATOR.join(
6374- p.encode('utf-8') for p in parts))
6375+ fh.write('%s\n' % self.FIELD_SEPARATOR.join(parts))
6376
6377 def add_link(self, source, dest):
6378 """Add a link to this manifest.
6379@@ -439,7 +435,7 @@ class InstallManifest(object):
6380 if install_type == self.CONTENT:
6381 # GeneratedFile expect the buffer interface, which the unicode
6382 # type doesn't have, so encode to a str.
6383- content = self._decode_field_entry(entry[1]).encode('utf-8')
6384+ content = self._decode_field_entry(entry[1])
6385 registry.add(dest, GeneratedFile(content))
6386 continue
6387
6388diff --git a/python/mozbuild/mozpack/mozjar.py b/python/mozbuild/mozpack/mozjar.py
6389index a723fd2c0..0b04d233c 100644
6390--- a/python/mozbuild/mozpack/mozjar.py
6391+++ b/python/mozbuild/mozpack/mozjar.py
6392@@ -2,7 +2,7 @@
6393 # License, v. 2.0. If a copy of the MPL was not distributed with this
6394 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6395
6396-from __future__ import absolute_import
6397+
6398
6399 from io import BytesIO
6400 import struct
6401@@ -14,9 +14,10 @@ from zipfile import (
6402 ZIP_DEFLATED,
6403 )
6404 from collections import OrderedDict
6405-from urlparse import urlparse, ParseResult
6406+from urllib.parse import urlparse, ParseResult
6407 import mozpack.path as mozpath
6408 from mozbuild.util import memoize
6409+from functools import reduce
6410
6411
6412 JAR_STORED = ZIP_STORED
6413@@ -72,7 +73,7 @@ class JarStruct(object):
6414 an instance with empty fields.
6415 '''
6416 assert self.MAGIC and isinstance(self.STRUCT, OrderedDict)
6417- self.size_fields = set(t for t in self.STRUCT.itervalues()
6418+ self.size_fields = set(t for t in self.STRUCT.values()
6419 if not t in JarStruct.TYPE_MAPPING)
6420 self._values = {}
6421 if data:
6422@@ -94,7 +95,7 @@ class JarStruct(object):
6423 # For all fields used as other fields sizes, keep track of their value
6424 # separately.
6425 sizes = dict((t, 0) for t in self.size_fields)
6426- for name, t in self.STRUCT.iteritems():
6427+ for name, t in self.STRUCT.items():
6428 if t in JarStruct.TYPE_MAPPING:
6429 value, size = JarStruct.get_data(t, data[offset:])
6430 else:
6431@@ -113,7 +114,7 @@ class JarStruct(object):
6432 Initialize an instance with empty fields.
6433 '''
6434 self.signature = self.MAGIC
6435- for name, t in self.STRUCT.iteritems():
6436+ for name, t in self.STRUCT.items():
6437 if name in self.size_fields:
6438 continue
6439 self._values[name] = 0 if t in JarStruct.TYPE_MAPPING else ''
6440@@ -138,9 +139,9 @@ class JarStruct(object):
6441 from self.STRUCT.
6442 '''
6443 serialized = struct.pack('<I', self.signature)
6444- sizes = dict((t, name) for name, t in self.STRUCT.iteritems()
6445+ sizes = dict((t, name) for name, t in self.STRUCT.items()
6446 if not t in JarStruct.TYPE_MAPPING)
6447- for name, t in self.STRUCT.iteritems():
6448+ for name, t in self.STRUCT.items():
6449 if t in JarStruct.TYPE_MAPPING:
6450 format, size = JarStruct.TYPE_MAPPING[t]
6451 if name in sizes:
6452@@ -159,7 +160,7 @@ class JarStruct(object):
6453 variable length fields.
6454 '''
6455 size = JarStruct.TYPE_MAPPING['uint32'][1]
6456- for name, type in self.STRUCT.iteritems():
6457+ for name, type in self.STRUCT.items():
6458 if type in JarStruct.TYPE_MAPPING:
6459 size += JarStruct.TYPE_MAPPING[type][1]
6460 else:
6461@@ -180,7 +181,7 @@ class JarStruct(object):
6462 return key in self._values
6463
6464 def __iter__(self):
6465- return self._values.iteritems()
6466+ return iter(self._values.items())
6467
6468 def __repr__(self):
6469 return "<%s %s>" % (self.__class__.__name__,
6470@@ -374,7 +375,7 @@ class JarReader(object):
6471 entries = self.entries
6472 if not entries:
6473 return JAR_STORED
6474- return max(f['compression'] for f in entries.itervalues())
6475+ return max(f['compression'] for f in entries.values())
6476
6477 @property
6478 def entries(self):
6479@@ -390,7 +391,7 @@ class JarReader(object):
6480 preload = JarStruct.get_data('uint32', self._data)[0]
6481 entries = OrderedDict()
6482 offset = self._cdir_end['cdir_offset']
6483- for e in xrange(self._cdir_end['cdir_entries']):
6484+ for e in range(self._cdir_end['cdir_entries']):
6485 entry = JarCdirEntry(self._data[offset:])
6486 offset += entry.size
6487 # Creator host system. 0 is MSDOS, 3 is Unix
6488@@ -452,7 +453,7 @@ class JarReader(object):
6489 for file in jarReader:
6490 ...
6491 '''
6492- for entry in self.entries.itervalues():
6493+ for entry in self.entries.values():
6494 yield self._getreader(entry)
6495
6496 def __getitem__(self, name):
6497@@ -547,7 +548,7 @@ class JarWriter(object):
6498 headers = {}
6499 preload_size = 0
6500 # Prepare central directory entries
6501- for entry, content in self._contents.itervalues():
6502+ for entry, content in self._contents.values():
6503 header = JarLocalFileHeader()
6504 for name in entry.STRUCT:
6505 if name in header:
6506@@ -562,7 +563,7 @@ class JarWriter(object):
6507 end['disk_entries'] = len(self._contents)
6508 end['cdir_entries'] = end['disk_entries']
6509 end['cdir_size'] = reduce(lambda x, y: x + y[0].size,
6510- self._contents.values(), 0)
6511+ list(self._contents.values()), 0)
6512 # On optimized archives, store the preloaded size and the central
6513 # directory entries, followed by the first end of central directory.
6514 if self._optimize:
6515@@ -571,18 +572,18 @@ class JarWriter(object):
6516 if preload_size:
6517 preload_size += offset
6518 self._data.write(struct.pack('<I', preload_size))
6519- for entry, _ in self._contents.itervalues():
6520+ for entry, _ in self._contents.values():
6521 entry['offset'] += offset
6522 self._data.write(entry.serialize())
6523 self._data.write(end.serialize())
6524 # Store local file entries followed by compressed data
6525- for entry, content in self._contents.itervalues():
6526+ for entry, content in self._contents.values():
6527 self._data.write(headers[entry].serialize())
6528 self._data.write(content)
6529 # On non optimized archives, store the central directory entries.
6530 if not self._optimize:
6531 end['cdir_offset'] = offset
6532- for entry, _ in self._contents.itervalues():
6533+ for entry, _ in self._contents.values():
6534 self._data.write(entry.serialize())
6535 # Store the end of central directory.
6536 self._data.write(end.serialize())
6537@@ -622,7 +623,7 @@ class JarWriter(object):
6538 deflater = data
6539 else:
6540 deflater = Deflater(compress, compress_level=self._compress_level)
6541- if isinstance(data, basestring):
6542+ if isinstance(data, str):
6543 deflater.write(data)
6544 elif hasattr(data, 'read'):
6545 if hasattr(data, 'seek'):
6546diff --git a/testing/mozbase/manifestparser/manifestparser/ini.py b/testing/mozbase/manifestparser/manifestparser/ini.py
6547index e5ba249c1..c141a18b7 100644
6548--- a/testing/mozbase/manifestparser/manifestparser/ini.py
6549+++ b/testing/mozbase/manifestparser/manifestparser/ini.py
6550@@ -2,7 +2,7 @@
6551 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
6552 # You can obtain one at http://mozilla.org/MPL/2.0/.
6553
6554-from __future__ import absolute_import
6555+
6556
6557 import os
6558 import sys
6559@@ -12,7 +12,7 @@ __all__ = ['read_ini', 'combine_fields']
6560
6561 class IniParseError(Exception):
6562 def __init__(self, fp, linenum, msg):
6563- if isinstance(fp, basestring):
6564+ if isinstance(fp, str):
6565 path = fp
6566 elif hasattr(fp, 'name'):
6567 path = fp.name
6568@@ -43,12 +43,15 @@ def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
6569 sections = []
6570 key = value = None
6571 section_names = set()
6572- if isinstance(fp, basestring):
6573+ if isinstance(fp, str):
6574 fp = file(fp)
6575
6576 # read the lines
6577 for (linenum, line) in enumerate(fp.read().splitlines(), start=1):
6578
6579+ if isinstance(line, bytes):
6580+ line = line.decode('utf-8')
6581+
6582 stripped = line.strip()
6583
6584 # ignore blank lines
6585@@ -66,7 +69,7 @@ def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
6586 inline_prefixes = {p: -1 for p in comments}
6587 while comment_start == sys.maxsize and inline_prefixes:
6588 next_prefixes = {}
6589- for prefix, index in inline_prefixes.items():
6590+ for prefix, index in list(inline_prefixes.items()):
6591 index = line.find(prefix, index+1)
6592 if index == -1:
6593 continue
6594@@ -163,7 +166,7 @@ def combine_fields(global_vars, local_vars):
6595 'support-files': '%s %s',
6596 }
6597 final_mapping = global_vars.copy()
6598- for field_name, value in local_vars.items():
6599+ for field_name, value in list(local_vars.items()):
6600 if field_name not in field_patterns or field_name not in global_vars:
6601 final_mapping[field_name] = value
6602 continue
6603diff --git a/testing/mozbase/manifestparser/manifestparser/manifestparser.py b/testing/mozbase/manifestparser/manifestparser/manifestparser.py
6604index 921369fd2..5b2f4c453 100755
6605--- a/testing/mozbase/manifestparser/manifestparser/manifestparser.py
6606+++ b/testing/mozbase/manifestparser/manifestparser/manifestparser.py
6607@@ -2,9 +2,9 @@
6608 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
6609 # You can obtain one at http://mozilla.org/MPL/2.0/.
6610
6611-from __future__ import absolute_import, print_function
6612
6613-from StringIO import StringIO
6614+
6615+from io import StringIO
6616 import json
6617 import fnmatch
6618 import os
6619@@ -23,7 +23,7 @@ from .filters import (
6620 __all__ = ['ManifestParser', 'TestManifest', 'convert']
6621
6622 relpath = os.path.relpath
6623-string = (basestring,)
6624+string = (str,)
6625
6626
6627 # path normalization
6628@@ -195,7 +195,7 @@ class ManifestParser(object):
6629
6630 # otherwise an item
6631 # apply ancestor defaults, while maintaining current file priority
6632- data = dict(self._ancestor_defaults.items() + data.items())
6633+ data = dict(list(self._ancestor_defaults.items()) + list(data.items()))
6634
6635 test = data
6636 test['name'] = section
6637@@ -323,19 +323,19 @@ class ManifestParser(object):
6638 # make some check functions
6639 if inverse:
6640 def has_tags(test):
6641- return not tags.intersection(test.keys())
6642+ return not tags.intersection(list(test.keys()))
6643
6644 def dict_query(test):
6645- for key, value in kwargs.items():
6646+ for key, value in list(kwargs.items()):
6647 if test.get(key) == value:
6648 return False
6649 return True
6650 else:
6651 def has_tags(test):
6652- return tags.issubset(test.keys())
6653+ return tags.issubset(list(test.keys()))
6654
6655 def dict_query(test):
6656- for key, value in kwargs.items():
6657+ for key, value in list(kwargs.items()):
6658 if test.get(key) != value:
6659 return False
6660 return True
6661@@ -359,7 +359,7 @@ class ManifestParser(object):
6662 if tests is None:
6663 manifests = []
6664 # Make sure to return all the manifests, even ones without tests.
6665- for manifest in self.manifest_defaults.keys():
6666+ for manifest in list(self.manifest_defaults.keys()):
6667 if isinstance(manifest, tuple):
6668 parentmanifest, manifest = manifest
6669 if manifest not in manifests:
6670@@ -409,7 +409,7 @@ class ManifestParser(object):
6671 """
6672
6673 files = set([])
6674- if isinstance(directories, basestring):
6675+ if isinstance(directories, str):
6676 directories = [directories]
6677
6678 # get files in directories
6679@@ -476,7 +476,7 @@ class ManifestParser(object):
6680 print('[DEFAULT]', file=fp)
6681 for tag in global_tags:
6682 print('%s =' % tag, file=fp)
6683- for key, value in global_kwargs.items():
6684+ for key, value in list(global_kwargs.items()):
6685 print('%s = %s' % (key, value), file=fp)
6686 print(file=fp)
6687
6688@@ -602,7 +602,7 @@ class ManifestParser(object):
6689 internal function to import directories
6690 """
6691
6692- if isinstance(pattern, basestring):
6693+ if isinstance(pattern, str):
6694 patterns = [pattern]
6695 else:
6696 patterns = pattern
6697diff --git a/testing/mozbase/mozinfo/mozinfo/mozinfo.py b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
6698index 90c187568..6c5a1f322 100755
6699--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
6700+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
6701@@ -8,7 +8,7 @@
6702 # linux) to the information; I certainly wouldn't want anyone parsing this
6703 # information and having behaviour depend on it
6704
6705-from __future__ import absolute_import, print_function
6706+
6707
6708 import os
6709 import platform
6710@@ -24,7 +24,7 @@ _os = os
6711 class unknown(object):
6712 """marker class for unknown information"""
6713
6714- def __nonzero__(self):
6715+ def __bool__(self):
6716 return False
6717
6718 def __str__(self):
6719@@ -96,20 +96,17 @@ elif system.startswith(('MINGW', 'MSYS_NT')):
6720 info['os'] = 'win'
6721 os_version = version = unknown
6722 elif system == "Linux":
6723- if hasattr(platform, "linux_distribution"):
6724- (distro, os_version, codename) = platform.linux_distribution()
6725- else:
6726- (distro, os_version, codename) = platform.dist()
6727 if not processor:
6728 processor = machine
6729- version = "%s %s" % (distro, os_version)
6730+
6731+ distro = 'OE/Yocto'
6732+ os_version = version = unknown
6733
6734 # Bug in Python 2's `platform` library:
6735 # It will return a triple of empty strings if the distribution is not supported.
6736 # It works on Python 3. If we don't have an OS version,
6737 # the unit tests fail to run.
6738 if not distro and not os_version and not codename:
6739- distro = 'lfs'
6740 version = release
6741 os_version = release
6742
6743@@ -131,7 +128,7 @@ else:
6744 os_version = version = unknown
6745
6746 info['version'] = version
6747-info['os_version'] = StringVersion(os_version)
6748+info['os_version'] = version
6749
6750 # processor type and bits
6751 if processor in ["i386", "i686"]:
6752@@ -188,12 +185,7 @@ def update(new_info):
6753 to a json file containing the new info.
6754 """
6755
6756- PY3 = sys.version_info[0] == 3
6757- if PY3:
6758- string_types = str,
6759- else:
6760- string_types = basestring,
6761- if isinstance(new_info, string_types):
6762+ if isinstance(new_info, str):
6763 # lazy import
6764 import mozfile
6765 import json
6766@@ -295,7 +287,7 @@ def main(args=None):
6767
6768 # print out choices if requested
6769 flag = False
6770- for key, value in options.__dict__.items():
6771+ for key, value in list(options.__dict__.items()):
6772 if value is True:
6773 print('%s choices: %s' % (key, ' '.join([str(choice)
6774 for choice in choices[key]])))
6775@@ -304,7 +296,7 @@ def main(args=None):
6776 return
6777
6778 # otherwise, print out all info
6779- for key, value in info.items():
6780+ for key, value in list(info.items()):
6781 print('%s: %s' % (key, value))
6782
6783
6784diff --git a/testing/mozbase/mozprocess/mozprocess/processhandler.py b/testing/mozbase/mozprocess/mozprocess/processhandler.py
6785index 3efb650b7..2575a4702 100644
6786--- a/testing/mozbase/mozprocess/mozprocess/processhandler.py
6787+++ b/testing/mozbase/mozprocess/mozprocess/processhandler.py
6788@@ -2,7 +2,7 @@
6789 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
6790 # You can obtain one at http://mozilla.org/MPL/2.0/.
6791
6792-from __future__ import absolute_import, print_function
6793+
6794
6795 import errno
6796 import os
6797@@ -13,7 +13,7 @@ import threading
6798 import time
6799 import traceback
6800
6801-from Queue import Queue, Empty
6802+from queue import Queue, Empty
6803 from datetime import datetime
6804
6805
6806@@ -124,14 +124,14 @@ class ProcessHandlerMixin(object):
6807 thread = threading.current_thread().name
6808 print("DBG::MOZPROC PID:{} ({}) | {}".format(self.pid, thread, msg))
6809
6810- def __del__(self, _maxint=sys.maxint):
6811+ def __del__(self, _maxint=sys.maxsize):
6812 if isWin:
6813 handle = getattr(self, '_handle', None)
6814 if handle:
6815 if hasattr(self, '_internal_poll'):
6816 self._internal_poll(_deadstate=_maxint)
6817 else:
6818- self.poll(_deadstate=sys.maxint)
6819+ self.poll(_deadstate=sys.maxsize)
6820 if handle or self._job or self._io_port:
6821 self._cleanup()
6822 else:
6823@@ -243,7 +243,7 @@ class ProcessHandlerMixin(object):
6824 p2cread, p2cwrite,
6825 c2pread, c2pwrite,
6826 errread, errwrite) = args_tuple
6827- if not isinstance(args, basestring):
6828+ if not isinstance(args, str):
6829 args = subprocess.list2cmdline(args)
6830
6831 # Always or in the create new process group
6832diff --git a/third_party/python/which/which.py b/third_party/python/which/which.py
6833index 9c7d10835..f02b2616e 100644
6834--- a/third_party/python/which/which.py
6835+++ b/third_party/python/which/which.py
6836@@ -90,13 +90,13 @@ def _getRegisteredExecutable(exeName):
6837 if sys.platform.startswith('win'):
6838 if os.path.splitext(exeName)[1].lower() != '.exe':
6839 exeName += '.exe'
6840- import _winreg
6841+ import winreg
6842 try:
6843 key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +\
6844 exeName
6845- value = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, key)
6846+ value = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, key)
6847 registered = (value, "from HKLM\\"+key)
6848- except _winreg.error:
6849+ except winreg.error:
6850 pass
6851 if registered and not os.path.exists(registered[0]):
6852 registered = None
6853@@ -244,7 +244,7 @@ def which(command, path=None, verbose=0, exts=None):
6854 If no match is found for the command, a WhichError is raised.
6855 """
6856 try:
6857- match = whichgen(command, path, verbose, exts).next()
6858+ match = next(whichgen(command, path, verbose, exts))
6859 except StopIteration:
6860 raise WhichError("Could not find '%s' on the path." % command)
6861 return match
6862@@ -281,17 +281,17 @@ def main(argv):
6863 try:
6864 optlist, args = getopt.getopt(argv[1:], 'haVvqp:e:',
6865 ['help', 'all', 'version', 'verbose', 'quiet', 'path=', 'exts='])
6866- except getopt.GetoptError, msg:
6867+ except getopt.GetoptError as msg:
6868 sys.stderr.write("which: error: %s. Your invocation was: %s\n"\
6869 % (msg, argv))
6870 sys.stderr.write("Try 'which --help'.\n")
6871 return 1
6872 for opt, optarg in optlist:
6873 if opt in ('-h', '--help'):
6874- print _cmdlnUsage
6875+ print(_cmdlnUsage)
6876 return 0
6877 elif opt in ('-V', '--version'):
6878- print "which %s" % __version__
6879+ print("which %s" % __version__)
6880 return 0
6881 elif opt in ('-a', '--all'):
6882 all = 1
6883@@ -319,9 +319,9 @@ def main(argv):
6884 nmatches = 0
6885 for match in whichgen(arg, path=altpath, verbose=verbose, exts=exts):
6886 if verbose:
6887- print "%s (%s)" % match
6888+ print("%s (%s)" % match)
6889 else:
6890- print match
6891+ print(match)
6892 nmatches += 1
6893 if not all:
6894 break
6895--
68962.21.0
6897