summaryrefslogblamecommitdiff
path: root/user/mozjs/python3.patch
blob: 65fc9da53c48eff3536dbce871bd04ee5bd58366 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481








































































































































































































































































































































































































































                                                                                             













































































































































































































































































































































































































































































































































                                                                                                                      

























































































































































































































                                                                                                                                                              





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                              












































































































































































































































                                                                                                    




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                    
































































































































































































































































































































































































































































                                                                                         

















































































































































































































                                                                                                                                              


















































































































































































































































                                                                                                                                                  

























































































































                                                                                           






































































































































































































































































































                                                                                                           























































































































































































































































































































































































































































































































































































































































































































































                                                                                                           



























































































































































































































































































































































                                                                                                                      





































































                                                                                                   
--- mozjs-52.4.0/python/mozbuild/dumbmake/dumbmake.py	(original)
+++ mozjs-52.4.0/python/mozbuild/dumbmake/dumbmake.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 from collections import OrderedDict
 from itertools import groupby
@@ -36,7 +36,7 @@
     deps = {}
 
     for i, (indent, target) in enumerate(pairs):
-        if not deps.has_key(target):
+        if target not in deps:
             deps[target] = []
 
         for j in range(i+1, len(pairs)):
@@ -68,7 +68,7 @@
                     del all_targets[dependency]
                 all_targets[dependency] = True
 
-    return all_targets.keys()
+    return list(all_targets.keys())
 
 def get_components(path):
     """Take a path and return all the components of the path."""
@@ -114,7 +114,7 @@
                 make_dirs[make_dir] = True
 
     all_components = []
-    for make_dir in make_dirs.iterkeys():
+    for make_dir in make_dirs.keys():
         all_components.extend(get_components(make_dir))
 
     for i in all_dependencies(*all_components, dependency_map=dependency_map):
--- mozjs-52.4.0/python/mozbuild/dumbmake/test/test_dumbmake.py	(original)
+++ mozjs-52.4.0/python/mozbuild/dumbmake/test/test_dumbmake.py	(refactored)
@@ -1,7 +1,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
-from __future__ import unicode_literals
+
 
 import unittest
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/android_version_code.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/android_version_code.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function
+
 
 import argparse
 import math
--- mozjs-52.4.0/python/mozbuild/mozbuild/artifacts.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/artifacts.py	(refactored)
@@ -40,7 +40,7 @@
 '''
 
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import collections
 import functools
@@ -57,7 +57,7 @@
 import subprocess
 import tarfile
 import tempfile
-import urlparse
+import urllib.parse
 import zipfile
 
 import pylru
@@ -183,7 +183,7 @@
 
         with JarWriter(file=processed_filename, optimize=False, compress_level=5) as writer:
             reader = JarReader(filename)
-            for filename, entry in reader.entries.iteritems():
+            for filename, entry in reader.entries.items():
                 for pattern, (src_prefix, dest_prefix) in self.test_artifact_patterns:
                     if not mozpath.match(filename, pattern):
                         continue
@@ -552,7 +552,7 @@
 
     def print_cache(self):
         with self:
-            for item in self._cache.items():
+            for item in list(self._cache.items()):
                 self.log(logging.INFO, 'artifact',
                     {'item': item},
                     '{item}')
@@ -565,7 +565,7 @@
         # We use the persisted LRU caches to our advantage.  The first item is
         # most recent.
         with self:
-            item = next(self._cache.items(), None)
+            item = next(list(self._cache.items()), None)
             if item is not None:
                 (name, args, sorted_kwargs), result = item
                 self.print_last_item(args, sorted_kwargs, result)
@@ -593,10 +593,10 @@
                          'changeset={changeset}&version=2&tipsonly=1')
         req = requests.get(cset_url_tmpl.format(tree=tree, changeset=revision),
                            headers={'Accept': 'application/json'})
-        if req.status_code not in range(200, 300):
+        if req.status_code not in list(range(200, 300)):
             raise ValueError
         result = req.json()
-        [found_pushid] = result['pushes'].keys()
+        [found_pushid] = list(result['pushes'].keys())
         return int(found_pushid)
 
     @cachedmethod(operator.attrgetter('_cache'))
@@ -609,7 +609,7 @@
                            headers={'Accept': 'application/json'})
         result = req.json()
         return [
-            p['changesets'][-1] for p in result['pushes'].values()
+            p['changesets'][-1] for p in list(result['pushes'].values())
         ]
 
 class TaskCache(CacheManager):
@@ -847,7 +847,7 @@
 
             candidate_pushheads = collections.defaultdict(list)
 
-            for tree, pushid in found_pushids.iteritems():
+            for tree, pushid in found_pushids.items():
                 end = pushid
                 start = pushid - NUM_PUSHHEADS_TO_QUERY_PER_PARENT
 
@@ -1052,7 +1052,7 @@
         """
         if source and os.path.isfile(source):
             return self.install_from_file(source, distdir)
-        elif source and urlparse.urlparse(source).scheme:
+        elif source and urllib.parse.urlparse(source).scheme:
             return self.install_from_url(source, distdir)
         else:
             if source is None and 'MOZ_ARTIFACT_REVISION' in os.environ:
--- mozjs-52.4.0/python/mozbuild/mozbuild/base.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/base.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import json
 import logging
@@ -482,7 +482,7 @@
             for flag in flags:
                 if flag == '-j':
                     try:
-                        flag = flags.next()
+                        flag = next(flags)
                     except StopIteration:
                         break
                     try:
--- mozjs-52.4.0/python/mozbuild/mozbuild/config_status.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/config_status.py	(refactored)
@@ -6,7 +6,7 @@
 # drop-in replacement for autoconf 2.13's config.status, with features
 # borrowed from autoconf > 2.5, and additional features.
 
-from __future__ import absolute_import, print_function
+
 
 import logging
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/doctor.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/doctor.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import subprocess
@@ -83,7 +83,7 @@
         valid = False
         while not valid and limit > 0:
             try:
-                choice = strtobool(raw_input(prompt + '[Y/N]\n'))
+                choice = strtobool(input(prompt + '[Y/N]\n'))
                 valid = True
             except ValueError:
                 print("ERROR! Please enter a valid option!")
@@ -103,11 +103,11 @@
             if status == 'SKIPPED':
                 continue
             self.results.append(result)
-            print('%s...\t%s\n' % (
+            print(('%s...\t%s\n' % (
                    result.get('desc', ''),
                    status
                 )
-            ).expandtabs(40)
+            ).expandtabs(40))
 
     @property
     def platform(self):
@@ -212,7 +212,7 @@
                         fsutil_output = subprocess.check_output(command)
                         status = 'GOOD, FIXED'
                         desc = 'lastaccess disabled systemwide'
-                    except subprocess.CalledProcessError, e:
+                    except subprocess.CalledProcessError as e:
                         desc = 'lastaccess enabled systemwide'
                         if e.output.find('denied') != -1:
                             status = 'BAD, FIX DENIED'
--- mozjs-52.4.0/python/mozbuild/mozbuild/dotproperties.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/dotproperties.py	(refactored)
@@ -5,7 +5,7 @@
 # This file contains utility functions for reading .properties files, like
 # region.properties.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import codecs
 import re
@@ -14,7 +14,7 @@
 if sys.version_info[0] == 3:
     str_type = str
 else:
-    str_type = basestring
+    str_type = str
 
 class DotProperties:
     r'''A thin representation of a key=value .properties file.'''
@@ -52,7 +52,7 @@
         if not prefix.endswith('.'):
             prefix = prefix + '.'
         indexes = []
-        for k, v in self._properties.iteritems():
+        for k, v in self._properties.items():
             if not k.startswith(prefix):
                 continue
             key = k[len(prefix):]
@@ -73,7 +73,7 @@
         if not prefix.endswith('.'):
             prefix = prefix + '.'
 
-        D = dict((k[len(prefix):], v) for k, v in self._properties.iteritems()
+        D = dict((k[len(prefix):], v) for k, v in self._properties.items()
                  if k.startswith(prefix) and '.' not in k[len(prefix):])
 
         for required_key in required_keys:
--- mozjs-52.4.0/python/mozbuild/mozbuild/html_build_viewer.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/html_build_viewer.py	(refactored)
@@ -4,16 +4,16 @@
 
 # This module contains code for running an HTTP server to view build info.
 
-from __future__ import absolute_import, unicode_literals
 
-import BaseHTTPServer
+
+import http.server
 import json
 import os
 
 import requests
 
 
-class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+class HTTPHandler(http.server.BaseHTTPRequestHandler):
     def do_GET(self):
         s = self.server.wrapper
         p = self.path
@@ -92,7 +92,7 @@
         self.doc_root = doc_root
         self.json_files = {}
 
-        self.server = BaseHTTPServer.HTTPServer((address, port), HTTPHandler)
+        self.server = http.server.HTTPServer((address, port), HTTPHandler)
         self.server.wrapper = self
         self.do_shutdown = False
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/jar.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/jar.py	(refactored)
@@ -8,7 +8,7 @@
 See the documentation for jar.mn on MDC for further details on the format.
 '''
 
-from __future__ import absolute_import
+
 
 import sys
 import os
@@ -17,7 +17,7 @@
 import logging
 from time import localtime
 from MozZipFile import ZipFile
-from cStringIO import StringIO
+from io import StringIO
 from collections import defaultdict
 
 from mozbuild.preprocessor import Preprocessor
@@ -302,9 +302,9 @@
         '''updateManifest replaces the % in the chrome registration entries
         with the given chrome base path, and updates the given manifest file.
         '''
-        myregister = dict.fromkeys(map(lambda s: s.replace('%',
-            chromebasepath), register))
-        addEntriesToListFile(manifestPath, myregister.iterkeys())
+        myregister = dict.fromkeys([s.replace('%',
+            chromebasepath) for s in register])
+        addEntriesToListFile(manifestPath, iter(myregister.keys()))
 
     def makeJar(self, infile, jardir):
         '''makeJar is the main entry point to JarMaker.
@@ -322,7 +322,7 @@
         elif self.relativesrcdir:
             self.localedirs = \
                 self.generateLocaleDirs(self.relativesrcdir)
-        if isinstance(infile, basestring):
+        if isinstance(infile, str):
             logging.info('processing ' + infile)
             self.sourcedirs.append(_normpath(os.path.dirname(infile)))
         pp = self.pp.clone()
@@ -372,7 +372,7 @@
             jarfilepath = jarfile + '.jar'
             try:
                 os.makedirs(os.path.dirname(jarfilepath))
-            except OSError, error:
+            except OSError as error:
                 if error.errno != errno.EEXIST:
                     raise
             jf = ZipFile(jarfilepath, 'a', lock=True)
@@ -514,7 +514,7 @@
             # remove previous link or file
             try:
                 os.remove(out)
-            except OSError, e:
+            except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
             return open(out, 'wb')
@@ -525,7 +525,7 @@
             if not os.path.isdir(outdir):
                 try:
                     os.makedirs(outdir)
-                except OSError, error:
+                except OSError as error:
                     if error.errno != errno.EEXIST:
                         raise
             return out
@@ -541,7 +541,7 @@
             # remove previous link or file
             try:
                 os.remove(out)
-            except OSError, e:
+            except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
             if sys.platform != 'win32':
--- mozjs-52.4.0/python/mozbuild/mozbuild/mach_commands.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/mach_commands.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import errno
@@ -136,7 +136,7 @@
         # terminal is a blessings.Terminal.
         self._t = terminal
         self._fh = sys.stdout
-        self.tiers = monitor.tiers.tier_status.viewitems()
+        self.tiers = monitor.tiers.tier_status.items()
 
     def clear(self):
         """Removes the footer from the current terminal."""
@@ -802,7 +802,7 @@
             dirpath = None
 
         type_counts = database.type_counts(dirpath)
-        sorted_counts = sorted(type_counts.iteritems(),
+        sorted_counts = sorted(iter(type_counts.items()),
             key=operator.itemgetter(1))
 
         total = 0
@@ -957,7 +957,7 @@
             processes[i].run()
 
         exit_code = 0
-        for process in processes.values():
+        for process in list(processes.values()):
             status = process.wait()
             if status:
                 exit_code = status
--- mozjs-52.4.0/python/mozbuild/mozbuild/makeutil.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/makeutil.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import re
@@ -66,7 +66,7 @@
         self._list = []
         self._set = set()
 
-    def __nonzero__(self):
+    def __bool__(self):
         return bool(self._set)
 
     def __iter__(self):
--- mozjs-52.4.0/python/mozbuild/mozbuild/mozconfig.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/mozconfig.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import filecmp
 import os
@@ -306,7 +306,7 @@
 
         # Environment variables also appear as shell variables, but that's
         # uninteresting duplication of information. Filter them out.
-        filt = lambda x, y: {k: v for k, v in x.items() if k not in y}
+        filt = lambda x, y: {k: v for k, v in list(x.items()) if k not in y}
         result['vars'] = diff_vars(
             filt(parsed['vars_before'], parsed['env_before']),
             filt(parsed['vars_after'], parsed['env_after'])
--- mozjs-52.4.0/python/mozbuild/mozbuild/mozinfo.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/mozinfo.py	(refactored)
@@ -5,7 +5,7 @@
 # This module produces a JSON file that provides basic build info and
 # configuration metadata.
 
-from __future__ import absolute_import
+
 
 import os
 import re
@@ -154,7 +154,7 @@
     and what keys are produced.
     """
     build_conf = build_dict(config, env)
-    if isinstance(file, basestring):
+    if isinstance(file, str):
         file = open(file, 'wb')
 
     json.dump(build_conf, file, sort_keys=True, indent=4)
--- mozjs-52.4.0/python/mozbuild/mozbuild/preprocessor.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/preprocessor.py	(refactored)
@@ -27,7 +27,8 @@
 import re
 from optparse import OptionParser
 import errno
-from makeutil import Makefile
+from .makeutil import Makefile
+from functools import reduce
 
 # hack around win32 mangling our line endings
 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443
@@ -56,7 +57,7 @@
         self.__ignore_whitespace()
         self.e = self.__get_logical_or()
         if self.content:
-            raise Expression.ParseError, self
+            raise Expression.ParseError(self)
 
     def __get_logical_or(self):
         """
@@ -157,7 +158,7 @@
                 if word_len:
                     rv = Expression.__ASTLeaf('string', self.content[:word_len])
                 else:
-                    raise Expression.ParseError, self
+                    raise Expression.ParseError(self)
         self.__strip(word_len)
         self.__ignore_whitespace()
         return rv
@@ -196,7 +197,7 @@
                 return left and right
             elif tok[1].value == '||':
                 return left or right
-            raise Expression.ParseError, self
+            raise Expression.ParseError(self)
 
         # Mapping from token types to evaluator functions
         # Apart from (non-)equality, all these can be simple lambda forms.
@@ -230,7 +231,7 @@
         def __repr__(self):
             return self.value.__repr__()
 
-    class ParseError(StandardError):
+    class ParseError(Exception):
         """
         Error raised when parsing fails.
         It has two members, offset and content, which give the offset of the
@@ -278,7 +279,7 @@
         self.context = Context()
         for k,v in {'FILE': '',
                     'LINE': 0,
-                    'DIRECTORY': os.path.abspath('.')}.iteritems():
+                    'DIRECTORY': os.path.abspath('.')}.items():
             self.context[k] = v
         self.actionLevel = 0
         self.disableLevel = 0
@@ -292,21 +293,21 @@
         self.cmds = {}
         for cmd, level in {'define': 0,
                            'undef': 0,
-                           'if': sys.maxint,
-                           'ifdef': sys.maxint,
-                           'ifndef': sys.maxint,
+                           'if': sys.maxsize,
+                           'ifdef': sys.maxsize,
+                           'ifndef': sys.maxsize,
                            'else': 1,
                            'elif': 1,
                            'elifdef': 1,
                            'elifndef': 1,
-                           'endif': sys.maxint,
+                           'endif': sys.maxsize,
                            'expand': 0,
                            'literal': 0,
                            'filter': 0,
                            'unfilter': 0,
                            'include': 0,
                            'includesubst': 0,
-                           'error': 0}.iteritems():
+                           'error': 0}.items():
             self.cmds[cmd] = (level, getattr(self, 'do_' + cmd))
         self.out = sys.stdout
         self.setMarker(marker)
@@ -469,7 +470,7 @@
                 raise Preprocessor.Error(self, "--depend doesn't work with stdout",
                                          None)
             try:
-                from makeutil import Makefile
+                from .makeutil import Makefile
             except:
                 raise Preprocessor.Error(self, "--depend requires the "
                                                "mozbuild.makeutil module", None)
@@ -684,7 +685,7 @@
         current = dict(self.filters)
         for f in filters:
             current[f] = getattr(self, 'filter_' + f)
-        filterNames = current.keys()
+        filterNames = list(current.keys())
         filterNames.sort()
         self.filters = [(fn, current[fn]) for fn in filterNames]
         return
@@ -694,7 +695,7 @@
         for f in filters:
             if f in current:
                 del current[f]
-        filterNames = current.keys()
+        filterNames = list(current.keys())
         filterNames.sort()
         self.filters = [(fn, current[fn]) for fn in filterNames]
         return
@@ -739,7 +740,7 @@
         args can either be a file name, or a file-like object.
         Files should be opened, and will be closed after processing.
         """
-        isName = type(args) == str or type(args) == unicode
+        isName = type(args) == str or type(args) == str
         oldCheckLineNumbers = self.checkLineNumbers
         self.checkLineNumbers = False
         if isName:
--- mozjs-52.4.0/python/mozbuild/mozbuild/pythonutil.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/pythonutil.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import sys
@@ -11,7 +11,7 @@
 def iter_modules_in_path(*paths):
     paths = [os.path.abspath(os.path.normcase(p)) + os.sep
              for p in paths]
-    for name, module in sys.modules.items():
+    for name, module in list(sys.modules.items()):
         if not hasattr(module, '__file__'):
             continue
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/shellutil.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/shellutil.py	(refactored)
@@ -15,7 +15,7 @@
     # which matches the pattern and captures it in a named match group.
     # The group names and patterns are given as arguments.
     all_tokens = '|'.join('(?P<%s>%s)' % (name, value)
-                          for name, value in tokens.iteritems())
+                          for name, value in tokens.items())
     nonescaped = r'(?<!\\)(?:%s)' % all_tokens
 
     # The final pattern matches either the above pattern, or an escaped
@@ -96,7 +96,7 @@
             self.cline = self.cline[m.end():]
 
             match = {name: value
-                     for name, value in m.groupdict().items() if value}
+                     for name, value in list(m.groupdict().items()) if value}
             if 'quote' in match:
                 # " or ' start a quoted string
                 if match['quote'] == '"':
@@ -144,7 +144,7 @@
             self._push(self.cline[:m.start()])
             self.cline = self.cline[m.end():]
             match = {name: value
-                     for name, value in m.groupdict().items() if value}
+                     for name, value in list(m.groupdict().items()) if value}
             if 'quote' in match:
                 # a double quote ends the quoted string, so go back to
                 # unquoted parsing
--- mozjs-52.4.0/python/mozbuild/mozbuild/sphinx.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/sphinx.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import importlib
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/testing.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/testing.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
-
-import cPickle as pickle
+
+
+import pickle as pickle
 import os
 import sys
 
@@ -62,7 +62,7 @@
         if test_defaults:
             with open(test_defaults, 'rb') as fh:
                 defaults = pickle.load(fh)
-        for path, tests in test_data.items():
+        for path, tests in list(test_data.items()):
             for metadata in tests:
                 if defaults:
                     manifest = metadata['manifest']
@@ -303,7 +303,7 @@
 WEB_PLATFORM_TESTS_FLAVORS = ('web-platform-tests',)
 
 def all_test_flavors():
-    return ([v[0] for v in TEST_MANIFESTS.values()] +
+    return ([v[0] for v in list(TEST_MANIFESTS.values())] +
             list(REFTEST_FLAVORS) +
             list(WEB_PLATFORM_TESTS_FLAVORS) +
             ['python'])
@@ -445,7 +445,7 @@
     only a few tests need to be run.
     """
     flavor_info = {flavor: (root, prefix, install)
-                   for (flavor, root, prefix, install) in TEST_MANIFESTS.values()}
+                   for (flavor, root, prefix, install) in list(TEST_MANIFESTS.values())}
     objdir_dest = mozpath.join(topobjdir, tests_root)
 
     converter = SupportFilesConverter()
@@ -527,7 +527,7 @@
         paths_file = os.path.join(context.config.topsrcdir, "testing",
                                   "web-platform", "tests", "tools", "localpaths.py")
         _globals = {"__file__": paths_file}
-        execfile(paths_file, _globals)
+        exec(compile(open(paths_file).read(), paths_file, 'exec'), _globals)
         import manifest as wptmanifest
     finally:
         sys.path = old_path
--- mozjs-52.4.0/python/mozbuild/mozbuild/util.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/util.py	(refactored)
@@ -5,7 +5,7 @@
 # This file contains miscellaneous utility functions that don't belong anywhere
 # in particular.
 
-from __future__ import absolute_import, unicode_literals, print_function
+
 
 import argparse
 import collections
@@ -36,7 +36,7 @@
 if sys.version_info[0] == 3:
     str_type = str
 else:
-    str_type = basestring
+    str_type = str
 
 if sys.platform == 'win32':
     _kernel32 = ctypes.windll.kernel32
@@ -78,7 +78,7 @@
     return h.hexdigest()
 
 
-class EmptyValue(unicode):
+class EmptyValue(str):
     """A dummy type that behaves like an empty string and sequence.
 
     This type exists in order to support
@@ -92,7 +92,7 @@
 class ReadOnlyNamespace(object):
     """A class for objects with immutable attributes set at initialization."""
     def __init__(self, **kwargs):
-        for k, v in kwargs.iteritems():
+        for k, v in kwargs.items():
             super(ReadOnlyNamespace, self).__setattr__(k, v)
 
     def __delattr__(self, key):
@@ -152,7 +152,7 @@
     if d and not os.path.exists(path):
         try:
             os.makedirs(d)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.EEXIST:
                 raise
 
@@ -224,7 +224,7 @@
         self.mode = mode
 
     def write(self, buf):
-        if isinstance(buf, unicode):
+        if isinstance(buf, str):
             buf = buf.encode('utf-8')
         BytesIO.write(self, buf)
 
@@ -381,7 +381,7 @@
     def __add__(self, other):
         # Allow None and EmptyValue is a special case because it makes undefined
         # variable references in moz.build behave better.
-        other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
+        other = [] if isinstance(other, (type(None), EmptyValue)) else other
         if not isinstance(other, list):
             raise ValueError('Only lists can be appended to lists.')
 
@@ -390,7 +390,7 @@
         return new_list
 
     def __iadd__(self, other):
-        other = [] if isinstance(other, (types.NoneType, EmptyValue)) else other
+        other = [] if isinstance(other, (type(None), EmptyValue)) else other
         if not isinstance(other, list):
             raise ValueError('Only lists can be appended to lists.')
 
@@ -542,14 +542,14 @@
     functions below.
     """
     assert isinstance(flags, dict)
-    assert all(isinstance(v, type) for v in flags.values())
+    assert all(isinstance(v, type) for v in list(flags.values()))
 
     class Flags(object):
-        __slots__ = flags.keys()
+        __slots__ = list(flags.keys())
         _flags = flags
 
         def update(self, **kwargs):
-            for k, v in kwargs.iteritems():
+            for k, v in kwargs.items():
                 setattr(self, k, v)
 
         def __getattr__(self, name):
@@ -1080,14 +1080,14 @@
     # issue.  So we do a little dance to filter it out ourselves.
     dummy_fill_value = ("dummy",)
     def filter_out_dummy(iterable):
-        return itertools.ifilter(lambda x: x != dummy_fill_value,
+        return filter(lambda x: x != dummy_fill_value,
                                  iterable)
 
     # From the itertools documentation, slightly modified:
     def grouper(n, iterable):
         "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
         args = [iter(iterable)] * n
-        return itertools.izip_longest(fillvalue=dummy_fill_value, *args)
+        return itertools.zip_longest(fillvalue=dummy_fill_value, *args)
 
     for i, unified_group in enumerate(grouper(files_per_unified_file,
                                               files)):
@@ -1104,7 +1104,7 @@
         [(1,2), (3,4), (5,6)]
     '''
     i = iter(iterable)
-    return itertools.izip_longest(i, i)
+    return itertools.zip_longest(i, i)
 
 
 VARIABLES_RE = re.compile('\$\((\w+)\)')
@@ -1122,7 +1122,7 @@
         value = variables.get(name)
         if not value:
             continue
-        if not isinstance(value, types.StringTypes):
+        if not isinstance(value, (str,)):
             value = ' '.join(value)
         result += value
     return result
@@ -1149,7 +1149,7 @@
     pass
 
 
-class EnumString(unicode):
+class EnumString(str):
     '''A string type that only can have a limited set of values, similarly to
     an Enum, and can only be compared against that set of values.
 
@@ -1185,19 +1185,18 @@
     # quoting could be done with either ' or ".
     if c == "'":
         return "\\'"
-    return unicode(c.encode('unicode_escape'))
+    return str(c.encode('unicode_escape'))
 
 # Mapping table between raw characters below \x80 and their escaped
 # counterpart, when they differ
 _INDENTED_REPR_TABLE = {
     c: e
-    for c, e in map(lambda x: (x, _escape_char(x)),
-                    map(unichr, range(128)))
+    for c, e in [(x, _escape_char(x)) for x in list(map(chr, list(range(128))))]
     if c != e
 }
 # Regexp matching all characters to escape.
 _INDENTED_REPR_RE = re.compile(
-    '([' + ''.join(_INDENTED_REPR_TABLE.values()) + ']+)')
+    '([' + ''.join(list(_INDENTED_REPR_TABLE.values())) + ']+)')
 
 
 def indented_repr(o, indent=4):
@@ -1223,7 +1222,7 @@
         elif isinstance(o, bytes):
             yield 'b'
             yield repr(o)
-        elif isinstance(o, unicode):
+        elif isinstance(o, str):
             yield "'"
             # We want a readable string (non escaped unicode), but some
             # special characters need escaping (e.g. \n, \t, etc.)
@@ -1253,11 +1252,11 @@
     if isinstance(obj, dict):
         return {
             encode(k, encoding): encode(v, encoding)
-            for k, v in obj.iteritems()
+            for k, v in obj.items()
         }
     if isinstance(obj, bytes):
         return obj
-    if isinstance(obj, unicode):
+    if isinstance(obj, str):
         return obj.encode(encoding)
     if isinstance(obj, Iterable):
         return [encode(i, encoding) for i in obj]
--- mozjs-52.4.0/python/mozbuild/mozbuild/vendor_rust.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/vendor_rust.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 from distutils.version import LooseVersion
 import logging
--- mozjs-52.4.0/python/mozbuild/mozbuild/virtualenv.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/virtualenv.py	(refactored)
@@ -5,7 +5,7 @@
 # This file contains code for populating the virtualenv environment for
 # Mozilla's build system. It is typically called as part of configure.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import distutils.sysconfig
 import os
@@ -461,8 +461,8 @@
         and call .ensure() and .activate() to make the virtualenv active.
         """
 
-        execfile(self.activate_path, dict(__file__=self.activate_path))
-        if isinstance(os.environ['PATH'], unicode):
+        exec(compile(open(self.activate_path).read(), self.activate_path, 'exec'), dict(__file__=self.activate_path))
+        if isinstance(os.environ['PATH'], str):
             os.environ['PATH'] = os.environ['PATH'].encode('utf-8')
 
     def install_pip_package(self, package):
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/buildlist.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/buildlist.py	(refactored)
@@ -7,7 +7,7 @@
 
 Usage: buildlist.py <filename> <entry> [<entry> ...]
 '''
-from __future__ import absolute_import, print_function
+
 
 import sys
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/cl.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/cl.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import ctypes
 import os
@@ -55,7 +55,7 @@
             break
 
     if target is None:
-        print >>sys.stderr, "No target set"
+        print("No target set", file=sys.stderr)
         return 1
 
     # Assume the source file is the last argument
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/dump_env.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/dump_env.py	(refactored)
@@ -6,5 +6,5 @@
 # native paths printed on Windows so that these paths can be incorporated
 # into Python configure's environment.
 import os
-for key, value in os.environ.items():
-    print('%s=%s' % (key, value))
+for key, value in list(os.environ.items()):
+    print(('%s=%s' % (key, value)))
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/file_generate.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/file_generate.py	(refactored)
@@ -6,7 +6,7 @@
 # the arguments that can be used to generate the output file, call the
 # script's |main| method with appropriate arguments.
 
-from __future__ import absolute_import, print_function
+
 
 import argparse
 import imp
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/generate_suggestedsites.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/generate_suggestedsites.py	(refactored)
@@ -26,7 +26,7 @@
 directory e.g. raw/suggestedsites.json, raw-pt-rBR/suggestedsites.json.
 '''
 
-from __future__ import absolute_import, print_function
+
 
 import argparse
 import copy
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/generate_symbols_file.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/generate_symbols_file.py	(refactored)
@@ -2,12 +2,12 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import buildconfig
 import os
-from StringIO import StringIO
+from io import StringIO
 from mozbuild.preprocessor import Preprocessor
 from mozbuild.util import DefinesAction
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/jar_maker.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/jar_maker.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import sys
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/make_dmg.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/make_dmg.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import print_function
+
 
 from mozbuild.base import MozbuildObject
 from mozpack import dmg
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/output_searchplugins_list.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/output_searchplugins_list.py	(refactored)
@@ -18,4 +18,4 @@
 else:
   engines = searchinfo["default"]["visibleDefaultEngines"]
 
-print '\n'.join(engines)
+print('\n'.join(engines))
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/package_fennec_apk.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/package_fennec_apk.py	(refactored)
@@ -6,7 +6,7 @@
 Script to produce an Android package (.apk) for Fennec.
 '''
 
-from __future__ import absolute_import, print_function
+
 
 import argparse
 import buildconfig
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/preprocessor.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/preprocessor.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import sys
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/process_define_files.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/process_define_files.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import os
@@ -55,7 +55,7 @@
                                 'CONFIGURE_DEFINE_FILE')
                         defines = '\n'.join(sorted(
                             '#define %s %s' % (name, val)
-                            for name, val in config.defines.iteritems()
+                            for name, val in config.defines.items()
                             if name not in config.non_global_defines))
                         l = l[:m.start('cmd') - 1] \
                             + defines + l[m.end('name'):]
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/process_install_manifest.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/process_install_manifest.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/test_archive.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/test_archive.py	(refactored)
@@ -8,7 +8,7 @@
 # It is defined inline because this was easiest to make test archive
 # generation faster.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import itertools
@@ -433,7 +433,7 @@
 # "common" is our catch all archive and it ignores things from other archives.
 # Verify nothing sneaks into ARCHIVE_FILES without a corresponding exclusion
 # rule in the "common" archive.
-for k, v in ARCHIVE_FILES.items():
+for k, v in list(ARCHIVE_FILES.items()):
     # Skip mozharness because it isn't staged.
     if k in ('common', 'mozharness'):
         continue
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/webidl.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/webidl.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import sys
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/xpccheck.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/xpccheck.py	(refactored)
@@ -8,7 +8,7 @@
 Usage: xpccheck.py <directory> [<directory> ...]
 '''
 
-from __future__ import absolute_import
+
 
 import sys
 import os
@@ -40,7 +40,7 @@
         break
    
     if not found:
-      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))
+      print("TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini')), file=sys.stderr)
       sys.exit(1)
 
 def verifyIniFile(initests, directory):
@@ -60,12 +60,12 @@
         break
 
     if not found:
-      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)
+      print("TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory), file=sys.stderr)
       sys.exit(1)
 
 def main(argv):
   if len(argv) < 2:
-    print >>sys.stderr, "Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]"
+    print("Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]", file=sys.stderr)
     sys.exit(1)
 
   topsrcdir = argv[0]
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/xpidl-process.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/xpidl-process.py	(refactored)
@@ -7,7 +7,7 @@
 # input IDL file(s). It's purpose is to directly support the build
 # system. The API will change to meet the needs of the build system.
 
-from __future__ import absolute_import
+
 
 import argparse
 import os
@@ -58,7 +58,7 @@
 
     # TODO use FileAvoidWrite once it supports binary mode.
     xpt_path = os.path.join(xpt_dir, '%s.xpt' % module)
-    xpt_link(xpts.values()).write(xpt_path)
+    xpt_link(list(xpts.values())).write(xpt_path)
 
     rule.add_targets([xpt_path])
     if deps_dir:
--- mozjs-52.4.0/python/mozbuild/mozbuild/action/zip.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/action/zip.py	(refactored)
@@ -5,7 +5,7 @@
 # This script creates a zip file, but will also strip any binaries
 # it finds before adding them to the zip.
 
-from __future__ import absolute_import
+
 
 from mozpack.files import FileFinder
 from mozpack.copier import Jarrer
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/base.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/base.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 from abc import (
     ABCMeta,
@@ -30,15 +30,13 @@
 from mozbuild.base import ExecutionSummary
 
 
-class BuildBackend(LoggingMixin):
+class BuildBackend(LoggingMixin, metaclass=ABCMeta):
     """Abstract base class for build backends.
 
     A build backend is merely a consumer of the build configuration (the output
     of the frontend processing). It does something with said data. What exactly
     is the discretion of the specific implementation.
     """
-
-    __metaclass__ = ABCMeta
 
     def __init__(self, environment):
         assert isinstance(environment, ConfigEnvironment)
@@ -252,7 +250,7 @@
         srcdir = mozpath.dirname(obj.input_path)
         pp.context.update({
             k: ' '.join(v) if isinstance(v, list) else v
-            for k, v in obj.config.substs.iteritems()
+            for k, v in obj.config.substs.items()
         })
         pp.context.update(
             top_srcdir=obj.topsrcdir,
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/common.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/common.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
-
-import cPickle as pickle
+
+
+import pickle as pickle
 import itertools
 import json
 import os
@@ -194,11 +194,11 @@
     def add_defaults(self, manifest):
         if not hasattr(manifest, 'manifest_defaults'):
             return
-        for sub_manifest, defaults in manifest.manifest_defaults.items():
+        for sub_manifest, defaults in list(manifest.manifest_defaults.items()):
             self.manifest_defaults[sub_manifest] = defaults
 
     def add_installs(self, obj, topsrcdir):
-        for src, (dest, _) in obj.installs.iteritems():
+        for src, (dest, _) in obj.installs.items():
             key = src[len(topsrcdir)+1:]
             self.installs_by_path[key].append((src, dest))
         for src, pat, dest in obj.pattern_installs:
@@ -379,7 +379,7 @@
 
         path = mozpath.join(self.environment.topobjdir, 'test-installs.pkl')
         with self._write_file(path, mode='rb') as fh:
-            pickle.dump({k: v for k, v in self._test_manager.installs_by_path.items()
+            pickle.dump({k: v for k, v in list(self._test_manager.installs_by_path.items())
                          if k in self._test_manager.deferred_installs},
                         fh,
                         protocol=2)
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/configenvironment.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/configenvironment.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import sys
@@ -17,7 +17,7 @@
 
 
 if sys.version_info.major == 2:
-    text_type = unicode
+    text_type = str
 else:
     text_type = str
 
@@ -176,7 +176,7 @@
                 except UnicodeDecodeError:
                     return v.decode('utf-8', 'replace')
 
-        for k, v in self.substs.items():
+        for k, v in list(self.substs.items()):
             if not isinstance(v, StringTypes):
                 if isinstance(v, Iterable):
                     type(v)(decode(i) for i in v)
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/cpp_eclipse.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/cpp_eclipse.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import errno
 import random
@@ -218,12 +218,12 @@
         cproject_header = cproject_header.replace('@MACH_COMMAND@', os.path.join(self.environment.topsrcdir, 'mach'))
         fh.write(cproject_header)
 
-        for path, defines in self._paths_to_defines.items():
+        for path, defines in list(self._paths_to_defines.items()):
             folderinfo = CPROJECT_TEMPLATE_FOLDER_INFO_HEADER
             folderinfo = folderinfo.replace('@FOLDER_ID@', str(random.randint(1000000, 99999999999)))
             folderinfo = folderinfo.replace('@FOLDER_NAME@', 'tree/' + path)
             fh.write(folderinfo)
-            for k, v in defines.items():
+            for k, v in list(defines.items()):
                 define = ET.Element('listOptionValue')
                 define.set('builtIn', 'false')
                 define.set('value', str(k) + "=" + str(v))
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/fastermake.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/fastermake.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals, print_function
+
 
 from mozbuild.backend.base import PartialBackend
 from mozbuild.backend.common import CommonBackend
@@ -130,12 +130,12 @@
             if value is not None:
                 mk.add_statement('%s = %s' % (var, value))
 
-        install_manifests_bases = self._install_manifests.keys()
+        install_manifests_bases = list(self._install_manifests.keys())
 
         # Add information for chrome manifest generation
         manifest_targets = []
 
-        for target, entries in self._manifest_entries.iteritems():
+        for target, entries in self._manifest_entries.items():
             manifest_targets.append(target)
             install_target = mozpath.basedir(target, install_manifests_bases)
             self._install_manifests[install_target].add_content(
@@ -144,16 +144,16 @@
 
         # Add information for install manifests.
         mk.add_statement('INSTALL_MANIFESTS = %s'
-                         % ' '.join(self._install_manifests.keys()))
+                         % ' '.join(list(self._install_manifests.keys())))
 
         # Add dependencies we infered:
-        for target, deps in self._dependencies.iteritems():
+        for target, deps in self._dependencies.items():
             mk.create_rule([target]).add_dependencies(
                 '$(TOPOBJDIR)/%s' % d for d in deps)
 
         mk.add_statement('include $(TOPSRCDIR)/config/faster/rules.mk')
 
-        for base, install_manifest in self._install_manifests.iteritems():
+        for base, install_manifest in self._install_manifests.items():
             with self._write_file(
                     mozpath.join(self.environment.topobjdir, 'faster',
                                  'install_%s' % base.replace('/', '_'))) as fh:
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/mach_commands.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/mach_commands.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import argparse
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/recursivemake.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/recursivemake.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import logging
 import os
@@ -12,7 +12,7 @@
     defaultdict,
     namedtuple,
 )
-from StringIO import StringIO
+from io import StringIO
 from itertools import chain
 
 from mozpack.manifests import (
@@ -74,6 +74,7 @@
 )
 from ..makeutil import Makefile
 from mozbuild.shellutil import quote as shell_quote
+from functools import reduce
 
 MOZBUILD_VARIABLES = [
     b'ANDROID_APK_NAME',
@@ -214,7 +215,7 @@
         self.fh.write(buf)
 
     def write_once(self, buf):
-        if isinstance(buf, unicode):
+        if isinstance(buf, str):
             buf = buf.encode('utf-8')
         if b'\n' + buf not in self.fh.getvalue():
             self.write(buf)
@@ -283,8 +284,8 @@
         Helper function to call a filter from compute_dependencies and
         traverse.
         """
-        return filter(current, self._traversal.get(current,
-            self.SubDirectories()))
+        return list(filter(current, self._traversal.get(current,
+            self.SubDirectories())))
 
     def compute_dependencies(self, filter=None):
         """
@@ -638,7 +639,7 @@
         convenience variables, and the other dependency definitions for a
         hopefully proper directory traversal.
         """
-        for tier, no_skip in self._no_skip.items():
+        for tier, no_skip in list(self._no_skip.items()):
             self.log(logging.DEBUG, 'fill_root_mk', {
                 'number': len(no_skip), 'tier': tier
                 }, 'Using {number} directories during {tier}')
@@ -684,7 +685,7 @@
         for tier, filter in filters:
             main, all_deps = \
                 self._traversal.compute_dependencies(filter)
-            for dir, deps in all_deps.items():
+            for dir, deps in list(all_deps.items()):
                 if deps is not None or (dir in self._idl_dirs \
                                         and tier == 'export'):
                     rule = root_deps_mk.create_rule(['%s/%s' % (dir, tier)])
@@ -697,7 +698,7 @@
                 rule.add_dependencies('%s/%s' % (d, tier) for d in main)
 
         all_compile_deps = reduce(lambda x,y: x|y,
-            self._compile_graph.values()) if self._compile_graph else set()
+            list(self._compile_graph.values())) if self._compile_graph else set()
         compile_roots = set(self._compile_graph.keys()) - all_compile_deps
 
         rule = root_deps_mk.create_rule(['recurse_compile'])
@@ -839,7 +840,7 @@
         self._fill_root_mk()
 
         # Make the master test manifest files.
-        for flavor, t in self._test_manifests.items():
+        for flavor, t in list(self._test_manifests.items()):
             install_prefix, manifests = t
             manifest_stem = mozpath.join(install_prefix, '%s.ini' % flavor)
             self._write_master_test_manifest(mozpath.join(
@@ -945,7 +946,7 @@
         for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done'):
             build_files.add_optional_exists(p)
 
-        for idl in manager.idls.values():
+        for idl in list(manager.idls.values()):
             self._install_manifests['dist_idl'].add_symlink(idl['source'],
                 idl['basename'])
             self._install_manifests['dist_include'].add_optional_exists('%s.h'
@@ -992,7 +993,7 @@
 
         interfaces_manifests = []
         dist_dir = mozpath.join(self.environment.topobjdir, 'dist')
-        for manifest, entries in manager.interface_manifests.items():
+        for manifest, entries in list(manager.interface_manifests.items()):
             interfaces_manifests.append(mozpath.join('$(DEPTH)', manifest))
             for xpt in sorted(entries):
                 registered_xpt_files.add(mozpath.join(
@@ -1052,7 +1053,7 @@
         # Don't allow files to be defined multiple times unless it is allowed.
         # We currently allow duplicates for non-test files or test files if
         # the manifest is listed as a duplicate.
-        for source, (dest, is_test) in obj.installs.items():
+        for source, (dest, is_test) in list(obj.installs.items()):
             try:
                 self._install_manifests['_test_files'].add_symlink(source, dest)
             except ValueError:
@@ -1386,7 +1387,7 @@
         man_dir = mozpath.join(self.environment.topobjdir, '_build_manifests',
             dest)
 
-        for k, manifest in manifests.items():
+        for k, manifest in list(manifests.items()):
             with self._write_file(mozpath.join(man_dir, k)) as fh:
                 manifest.write(fileobj=fh)
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/tup.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/tup.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import os
 
@@ -253,7 +253,7 @@
         backend_file = self._get_backend_file('xpcom/xpidl')
         backend_file.export_shell()
 
-        for module, data in sorted(manager.modules.iteritems()):
+        for module, data in sorted(manager.modules.items()):
             dest, idls = data
             cmd = [
                 '$(PYTHON_PATH)',
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/visualstudio.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/visualstudio.py	(refactored)
@@ -5,7 +5,7 @@
 # This file contains a build backend for generating Visual Studio project
 # files.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import errno
 import os
@@ -218,7 +218,7 @@
             includes = [os.path.normpath(i) for i in includes]
 
             defines = []
-            for k, v in self._paths_to_defines.get(path, {}).items():
+            for k, v in list(self._paths_to_defines.get(path, {}).items()):
                 if v is True:
                     defines.append(k)
                 else:
--- mozjs-52.4.0/python/mozbuild/mozbuild/codecoverage/chrome_map.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/codecoverage/chrome_map.py	(refactored)
@@ -5,7 +5,7 @@
 from collections import defaultdict
 import json
 import os
-import urlparse
+import urllib.parse
 
 from mach.config import ConfigSettings
 from mach.logging import LoggingManager
@@ -42,7 +42,7 @@
         if isinstance(entry, (ManifestChrome, ManifestResource)):
             if isinstance(entry, ManifestResource):
                 dest = entry.target
-                url = urlparse.urlparse(dest)
+                url = urllib.parse.urlparse(dest)
                 if not url.scheme:
                     dest = mozpath.normpath(mozpath.join(entry.base, dest))
                 if url.scheme == 'file':
@@ -99,7 +99,7 @@
             chrome_mapping = self.manifest_handler.chrome_mapping
             overrides = self.manifest_handler.overrides
             json.dump([
-                {k: list(v) for k, v in chrome_mapping.iteritems()},
+                {k: list(v) for k, v in chrome_mapping.items()},
                 overrides,
                 self._install_mapping,
             ], fh, sort_keys=True, indent=2)
--- mozjs-52.4.0/python/mozbuild/mozbuild/codecoverage/packager.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/codecoverage/packager.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function
+
 
 import argparse
 import sys
@@ -12,7 +12,7 @@
 
 def package_gcno_tree(root, output_file):
     # XXX JarWriter doesn't support unicode strings, see bug 1056859
-    if isinstance(root, unicode):
+    if isinstance(root, str):
         root = root.encode('utf-8')
 
     finder = FileFinder(root)
--- mozjs-52.4.0/python/mozbuild/mozbuild/compilation/codecomplete.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/compilation/codecomplete.py	(refactored)
@@ -4,7 +4,7 @@
 
 # This modules provides functionality for dealing with code completion.
 
-from __future__ import absolute_import
+
 
 import os
 
@@ -59,5 +59,5 @@
         # Drop the first flag since that is the pathname of the compiler.
         flags = (shell_split(build_vars[cc]) + shell_split(build_vars[name]))[1:]
 
-        print(' '.join(shell_quote(arg)
-                       for arg in util.sanitize_cflags(flags)))
+        print((' '.join(shell_quote(arg)
+                       for arg in util.sanitize_cflags(flags))))
--- mozjs-52.4.0/python/mozbuild/mozbuild/compilation/database.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/compilation/database.py	(refactored)
@@ -118,7 +118,7 @@
 
         db = []
 
-        for (directory, filename), cmd in self._db.iteritems():
+        for (directory, filename), cmd in self._db.items():
             env = self._envs[directory]
             cmd = list(cmd)
             cmd.append(filename)
@@ -151,7 +151,7 @@
                 a = expand_variables(a, variables).split()
                 if not a:
                     continue
-                if isinstance(a, types.StringTypes):
+                if isinstance(a, (str,)):
                     c.append(a)
                 else:
                     c.extend(a)
@@ -216,7 +216,7 @@
             value = cenv.substs.get(name)
             if not value:
                 return
-            if isinstance(value, types.StringTypes):
+            if isinstance(value, (str,)):
                 value = value.split()
             db.extend(value)
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/compilation/warnings.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/compilation/warnings.py	(refactored)
@@ -4,7 +4,7 @@
 
 # This modules provides functionality for dealing with compiler warnings.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import errno
 import json
@@ -123,18 +123,18 @@
 
     def __len__(self):
         i = 0
-        for value in self._files.values():
+        for value in list(self._files.values()):
             i += len(value['warnings'])
 
         return i
 
     def __iter__(self):
-        for value in self._files.values():
+        for value in list(self._files.values()):
             for warning in value['warnings']:
                 yield warning
 
     def __contains__(self, item):
-        for value in self._files.values():
+        for value in list(self._files.values()):
             for warning in value['warnings']:
                 if warning == item:
                     return True
@@ -144,7 +144,7 @@
     @property
     def warnings(self):
         """All the CompilerWarning instances in this database."""
-        for value in self._files.values():
+        for value in list(self._files.values()):
             for w in value['warnings']:
                 yield w
 
@@ -152,7 +152,7 @@
         """Returns a mapping of warning types to their counts."""
 
         types = {}
-        for value in self._files.values():
+        for value in list(self._files.values()):
             for warning in value['warnings']:
                 if dirpath and not mozpath.normsep(warning['filename']).startswith(dirpath):
                     continue
@@ -210,7 +210,7 @@
         """
 
         # Need to calculate up front since we are mutating original object.
-        filenames = self._files.keys()
+        filenames = list(self._files.keys())
         for filename in filenames:
             if not os.path.exists(filename):
                 del self._files[filename]
@@ -229,10 +229,10 @@
         obj = {'files': {}}
 
         # All this hackery because JSON can't handle sets.
-        for k, v in self._files.iteritems():
+        for k, v in self._files.items():
             obj['files'][k] = {}
 
-            for k2, v2 in v.iteritems():
+            for k2, v2 in v.items():
                 normalized = v2
 
                 if k2 == 'warnings':
@@ -249,8 +249,8 @@
         self._files = obj['files']
 
         # Normalize data types.
-        for filename, value in self._files.iteritems():
-            for k, v in value.iteritems():
+        for filename, value in self._files.items():
+            for k, v in value.items():
                 if k != 'warnings':
                     continue
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/__init__.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/__init__.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import inspect
 import logging
@@ -193,7 +193,7 @@
         for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
                   'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
                   'hasattr', 'enumerate', 'range', 'zip')
-    }, __import__=forbidden_import, str=unicode)
+    }, __import__=forbidden_import, str=str)
 
     # Expose a limited set of functions from os.path
     OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
@@ -333,7 +333,7 @@
         if path:
             self.include_file(path)
 
-        for option in self._options.itervalues():
+        for option in self._options.values():
             # All options must be referenced by some @depends function
             if option not in self._seen:
                 raise ConfigureError(
@@ -437,7 +437,7 @@
                     value = PositiveOptionValue()
                 elif value is False or value == ():
                     value = NegativeOptionValue()
-                elif isinstance(value, types.StringTypes):
+                elif isinstance(value, (str,)):
                     value = PositiveOptionValue((value,))
                 elif isinstance(value, tuple):
                     value = PositiveOptionValue(value)
@@ -477,7 +477,7 @@
         return value
 
     def _dependency(self, arg, callee_name, arg_name=None):
-        if isinstance(arg, types.StringTypes):
+        if isinstance(arg, (str,)):
             prefix, name, values = Option.split_option(arg)
             if values != ():
                 raise ConfigureError("Option must not contain an '='")
@@ -541,7 +541,7 @@
         '''
         when = self._normalize_when(kwargs.get('when'), 'option')
         args = [self._resolve(arg) for arg in args]
-        kwargs = {k: self._resolve(v) for k, v in kwargs.iteritems()
+        kwargs = {k: self._resolve(v) for k, v in kwargs.items()
                                       if k != 'when'}
         option = Option(*args, **kwargs)
         if when:
@@ -622,7 +622,7 @@
         with self.only_when_impl(when):
             what = self._resolve(what)
             if what:
-                if not isinstance(what, types.StringTypes):
+                if not isinstance(what, (str,)):
                     raise TypeError("Unexpected type: '%s'" % type(what).__name__)
                 self.include_file(what)
 
@@ -640,7 +640,7 @@
             (k[:-len('_impl')], getattr(self, k))
             for k in dir(self) if k.endswith('_impl') and k != 'template_impl'
         )
-        glob.update((k, v) for k, v in self.iteritems() if k not in glob)
+        glob.update((k, v) for k, v in self.items() if k not in glob)
 
         # Any function argument to the template must be prepared to be sandboxed.
         # If the template itself returns a function (in which case, it's very
@@ -664,7 +664,7 @@
             def wrapper(*args, **kwargs):
                 args = [maybe_prepare_function(arg) for arg in args]
                 kwargs = {k: maybe_prepare_function(v)
-                          for k, v in kwargs.iteritems()}
+                          for k, v in kwargs.items()}
                 ret = template(*args, **kwargs)
                 if isfunction(ret):
                     # We can't expect the sandboxed code to think about all the
@@ -696,7 +696,7 @@
         for value, required in (
                 (_import, True), (_from, False), (_as, False)):
 
-            if not isinstance(value, types.StringTypes) and (
+            if not isinstance(value, (str,)) and (
                     required or value is not None):
                 raise TypeError("Unexpected type: '%s'" % type(value).__name__)
             if value is not None and not self.RE_MODULE.match(value):
@@ -759,7 +759,7 @@
         name = self._resolve(name, need_help_dependency=False)
         if name is None:
             return
-        if not isinstance(name, types.StringTypes):
+        if not isinstance(name, (str,)):
             raise TypeError("Unexpected type: '%s'" % type(name).__name__)
         if name in data:
             raise ConfigureError(
@@ -849,7 +849,7 @@
                 if isinstance(possible_reasons[0], Option):
                     reason = possible_reasons[0]
         if not reason and (isinstance(value, (bool, tuple)) or
-                           isinstance(value, types.StringTypes)):
+                           isinstance(value, (str,))):
             # A reason can be provided automatically when imply_option
             # is called with an immediate value.
             _, filename, line, _, _, _ = inspect.stack()[1]
@@ -884,10 +884,10 @@
         if not inspect.isfunction(func):
             raise TypeError("Unexpected type: '%s'" % type(func).__name__)
         if func in self._prepared_functions:
-            return func, func.func_globals
+            return func, func.__globals__
 
         glob = SandboxedGlobal(
-            (k, v) for k, v in func.func_globals.iteritems()
+            (k, v) for k, v in func.__globals__.items()
             if (inspect.isfunction(v) and v not in self._templates) or (
                 inspect.isclass(v) and issubclass(v, Exception))
         )
@@ -908,20 +908,20 @@
         # Note this is not entirely bullet proof (if the value is e.g. a list,
         # the list contents could have changed), but covers the bases.
         closure = None
-        if func.func_closure:
+        if func.__closure__:
             def makecell(content):
                 def f():
                     content
-                return f.func_closure[0]
+                return f.__closure__[0]
 
             closure = tuple(makecell(cell.cell_contents)
-                            for cell in func.func_closure)
+                            for cell in func.__closure__)
 
         new_func = wraps(func)(types.FunctionType(
-            func.func_code,
+            func.__code__,
             glob,
             func.__name__,
-            func.func_defaults,
+            func.__defaults__,
             closure
         ))
         @wraps(new_func)
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/check_debug_ranges.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/check_debug_ranges.py	(refactored)
@@ -6,7 +6,7 @@
 # to a given compilation unit. This is used as a helper to find a bug in some
 # versions of GNU ld.
 
-from __future__ import absolute_import
+
 
 import subprocess
 import sys
@@ -59,4 +59,4 @@
 
 
 if __name__ == '__main__':
-    print main(*sys.argv[1:])
+    print(main(*sys.argv[1:]))
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/constants.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/constants.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 from mozbuild.util import EnumString
 from collections import OrderedDict
@@ -56,7 +56,7 @@
     'x86_64': 64,
 }
 
-CPU = EnumString.subclass(*CPU_bitness.keys())
+CPU = EnumString.subclass(*list(CPU_bitness.keys()))
 
 Endianness = EnumString.subclass(
     'big',
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/help.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/help.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import os
 from mozbuild.configure.options import Option
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/libstdcxx.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/libstdcxx.py	(refactored)
@@ -13,7 +13,7 @@
 # will be used from shell, we just print the two assignments and evaluate
 # them from shell.
 
-from __future__ import absolute_import
+
 
 import os
 import subprocess
@@ -76,6 +76,6 @@
 
 if __name__ == '__main__':
     cxx_env = os.environ['CXX']
-    print 'MOZ_LIBSTDCXX_TARGET_VERSION=%s' % find_version(cxx_env)
+    print('MOZ_LIBSTDCXX_TARGET_VERSION=%s' % find_version(cxx_env))
     host_cxx_env = os.environ.get('HOST_CXX', cxx_env)
-    print 'MOZ_LIBSTDCXX_HOST_VERSION=%s' % find_version(host_cxx_env)
+    print('MOZ_LIBSTDCXX_HOST_VERSION=%s' % find_version(host_cxx_env))
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/lint.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/lint.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
 
-from StringIO import StringIO
+
+from io import StringIO
 from . import (
     CombinedDependsFunction,
     ConfigureError,
@@ -42,7 +42,7 @@
             # - don't use @imports
             # - don't have a closure
             # - don't use global variables
-            if func in self._imports or func.func_closure:
+            if func in self._imports or func.__closure__:
                 return True
             for op, arg in disassemble_as_iter(func):
                 if op in ('LOAD_GLOBAL', 'STORE_GLOBAL'):
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/lint_util.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/lint_util.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import dis
 import inspect
@@ -12,9 +12,9 @@
 # returns an iterator.
 def disassemble_as_iter(co):
     if inspect.ismethod(co):
-        co = co.im_func
+        co = co.__func__
     if inspect.isfunction(co):
-        co = co.func_code
+        co = co.__code__
     code = co.co_code
     n = len(code)
     i = 0
@@ -30,7 +30,7 @@
             extended_arg = 0
             i += 2
             if op == dis.EXTENDED_ARG:
-                extended_arg = arg * 65536L
+                extended_arg = arg * 65536
                 continue
             if op in dis.hasconst:
                 yield opname, co.co_consts[arg]
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/options.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/options.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import os
 import sys
@@ -12,7 +12,7 @@
 
 def istupleofstrings(obj):
     return isinstance(obj, tuple) and len(obj) and all(
-        isinstance(o, types.StringTypes) for o in obj)
+        isinstance(o, (str,)) for o in obj)
 
 
 class OptionValue(tuple):
@@ -71,7 +71,7 @@
     in the form of a tuple for when values are given to the option (in the form
     --option=value[,value2...].
     '''
-    def __nonzero__(self):
+    def __bool__(self):
         return True
 
 
@@ -96,7 +96,7 @@
         if format_data:
             message = message.format(**format_data)
         super(ConflictingOptionError, self).__init__(message)
-        for k, v in format_data.iteritems():
+        for k, v in format_data.items():
             setattr(self, k, v)
 
 
@@ -132,7 +132,7 @@
                 'At least an option name or an environment variable name must '
                 'be given')
         if name:
-            if not isinstance(name, types.StringTypes):
+            if not isinstance(name, (str,)):
                 raise InvalidOptionError('Option must be a string')
             if not name.startswith('--'):
                 raise InvalidOptionError('Option must start with `--`')
@@ -141,7 +141,7 @@
             if not name.islower():
                 raise InvalidOptionError('Option must be all lowercase')
         if env:
-            if not isinstance(env, types.StringTypes):
+            if not isinstance(env, (str,)):
                 raise InvalidOptionError(
                     'Environment variable name must be a string')
             if not env.isupper():
@@ -151,8 +151,8 @@
                 isinstance(nargs, int) and nargs >= 0):
             raise InvalidOptionError(
                 "nargs must be a positive integer, '?', '*' or '+'")
-        if (not isinstance(default, types.StringTypes) and
-                not isinstance(default, (bool, types.NoneType)) and
+        if (not isinstance(default, (str,)) and
+                not isinstance(default, (bool, type(None))) and
                 not istupleofstrings(default)):
             raise InvalidOptionError(
                 'default must be a bool, a string or a tuple of strings')
@@ -224,7 +224,7 @@
                     ', '.join("'%s'" % c for c in choices))
         elif has_choices:
             maxargs = self.maxargs
-            if len(choices) < maxargs and maxargs != sys.maxint:
+            if len(choices) < maxargs and maxargs != sys.maxsize:
                 raise InvalidOptionError('Not enough `choices` for `nargs`')
         self.choices = choices
         self.help = help
@@ -238,7 +238,7 @@
         where prefix is one of 'with', 'without', 'enable' or 'disable'.
         The '=values' part is optional. Values are separated with commas.
         '''
-        if not isinstance(option, types.StringTypes):
+        if not isinstance(option, (str,)):
             raise InvalidOptionError('Option must be a string')
 
         elements = option.split('=', 1)
@@ -291,7 +291,7 @@
     def maxargs(self):
         if isinstance(self.nargs, int):
             return self.nargs
-        return 1 if self.nargs == '?' else sys.maxint
+        return 1 if self.nargs == '?' else sys.maxsize
 
     def _validate_nargs(self, num):
         minargs, maxargs = self.minargs, self.maxargs
@@ -485,5 +485,5 @@
 
     def __iter__(self):
         for d in (self._args, self._extra_args):
-            for arg, pos in d.itervalues():
+            for arg, pos in d.values():
                 yield arg
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/util.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/configure/util.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import codecs
 import itertools
@@ -52,7 +52,7 @@
 
     def __cmp__(self, other):
         # LooseVersion checks isinstance(StringType), so work around it.
-        if isinstance(other, unicode):
+        if isinstance(other, str):
             other = other.encode('ascii')
         return LooseVersion.__cmp__(self, other)
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/controller/building.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/controller/building.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import getpass
 import json
@@ -108,7 +108,7 @@
         """
         o = []
 
-        for tier, state in self.tiers.items():
+        for tier, state in list(self.tiers.items()):
             t_entry = dict(
                 name=tier,
                 start=state['begin_time'],
@@ -643,8 +643,8 @@
 
         return '\n'.join(lines)
 
-    def __nonzero__(self):
-        relative_values = [v for k, v in self._values.items()
+    def __bool__(self):
+        relative_values = [v for k, v in list(self._values.items())
                            if k not in self.ABSOLUTE_KEYS]
         return (all(v >= 0 for v in relative_values) and
                 any(v > 0 for v in relative_values))
@@ -666,8 +666,8 @@
         """Install test files."""
 
         if self.is_clobber_needed():
-            print(INSTALL_TESTS_CLOBBER.format(
-                  clobber_file=os.path.join(self.topobjdir, 'CLOBBER')))
+            print((INSTALL_TESTS_CLOBBER.format(
+                  clobber_file=os.path.join(self.topobjdir, 'CLOBBER'))))
             sys.exit(1)
 
         if not test_objs:
--- mozjs-52.4.0/python/mozbuild/mozbuild/controller/clobber.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/controller/clobber.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function
+
 
 r'''This module contains code for managing clobbering of the tree.'''
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/context.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/context.py	(refactored)
@@ -14,7 +14,7 @@
 contain, you've come to the right place.
 """
 
-from __future__ import absolute_import, unicode_literals
+
 
 import os
 
@@ -234,15 +234,15 @@
         This function is transactional: if setitem fails for one of the values,
         the context is not updated at all."""
         if isinstance(iterable, dict):
-            iterable = iterable.items()
+            iterable = list(iterable.items())
 
         update = {}
-        for key, value in itertools.chain(iterable, kwargs.items()):
+        for key, value in itertools.chain(iterable, list(kwargs.items())):
             stored_type = self._validate(key, value)
             # Don't create an instance of stored_type if coercion is needed,
             # until all values are validated.
             update[key] = (value, stored_type)
-        for key, (value, stored_type) in update.items():
+        for key, (value, stored_type) in list(update.items()):
             if not isinstance(value, stored_type):
                 update[key] = stored_type(value)
             else:
@@ -297,7 +297,7 @@
             self.update(value)
 
 
-class FinalTargetValue(ContextDerivedValue, unicode):
+class FinalTargetValue(ContextDerivedValue, str):
     def __new__(cls, context, value=""):
         if not value:
             value = 'dist/'
@@ -307,7 +307,7 @@
                 value += 'bin'
             if context['DIST_SUBDIR']:
                 value += '/' + context['DIST_SUBDIR']
-        return unicode.__new__(cls, value)
+        return str.__new__(cls, value)
 
 
 def Enum(*values):
@@ -355,7 +355,7 @@
                 cls = SourcePath
         return super(PathMeta, cls).__call__(context, value)
 
-class Path(ContextDerivedValue, unicode):
+class Path(ContextDerivedValue, str, metaclass=PathMeta):
     """Stores and resolves a source path relative to a given context
 
     This class is used as a backing type for some of the sandbox variables.
@@ -366,7 +366,6 @@
       - '!objdir/relative/paths'
       - '%/filesystem/absolute/paths'
     """
-    __metaclass__ = PathMeta
 
     def __new__(cls, context, value=None):
         return super(Path, cls).__new__(cls, value)
@@ -386,7 +385,7 @@
     def __cmp__(self, other):
         if isinstance(other, Path) and self.srcdir != other.srcdir:
             return cmp(self.full_path, other.full_path)
-        return cmp(unicode(self), other)
+        return cmp(str(self), other)
 
     # __cmp__ is not enough because unicode has __eq__, __ne__, etc. defined
     # and __cmp__ is only used for those when they don't exist.
@@ -544,7 +543,7 @@
         __slots__ = tuple([name for name, _ in fields])
 
         def __init__(self, context):
-            for fname, ftype in self._fields.items():
+            for fname, ftype in list(self._fields.items()):
                 if issubclass(ftype, ContextDerivedValue):
                     setattr(self, fname, self._fields[fname](context))
                 else:
@@ -614,8 +613,8 @@
     return _TypedListWithAction
 
 WebPlatformTestManifest = TypedNamedTuple("WebPlatformTestManifest",
-                                          [("manifest_path", unicode),
-                                           ("test_root", unicode)])
+                                          [("manifest_path", str),
+                                           ("test_root", str)])
 ManifestparserManifestList = OrderedListWithAction(read_manifestparser_manifest)
 ReftestManifestList = OrderedListWithAction(read_reftest_manifest)
 WptManifestList = TypedListWithAction(WebPlatformTestManifest, read_wpt_manifest)
@@ -623,12 +622,12 @@
 OrderedSourceList = ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList)
 OrderedTestFlavorList = TypedList(Enum(*all_test_flavors()),
                                   StrictOrderingOnAppendList)
-OrderedStringList = TypedList(unicode, StrictOrderingOnAppendList)
+OrderedStringList = TypedList(str, StrictOrderingOnAppendList)
 DependentTestsEntry = ContextDerivedTypedRecord(('files', OrderedSourceList),
                                                 ('tags', OrderedStringList),
                                                 ('flavors', OrderedTestFlavorList))
 BugzillaComponent = TypedNamedTuple('BugzillaComponent',
-                        [('product', unicode), ('component', unicode)])
+                        [('product', str), ('component', str)])
 
 
 class Files(SubContext):
@@ -764,7 +763,7 @@
         self.test_tags |= other.test_tags
         self.test_flavors |= other.test_flavors
 
-        for k, v in other.items():
+        for k, v in list(other.items()):
             if k == 'IMPACTED_TESTS':
                 self.test_files |= set(mozpath.relpath(e.full_path, e.context.config.topsrcdir)
                                        for e in v.files)
@@ -818,7 +817,7 @@
 
         bug_components = Counter()
 
-        for f in files.values():
+        for f in list(files.values()):
             bug_component = f.get('BUG_COMPONENT')
             if bug_component:
                 bug_components[bug_component] += 1
@@ -889,11 +888,11 @@
         file.
         """),
 
-    'ANDROID_APK_NAME': (unicode, unicode,
+    'ANDROID_APK_NAME': (str, str,
         """The name of an Android APK file to generate.
         """),
 
-    'ANDROID_APK_PACKAGE': (unicode, unicode,
+    'ANDROID_APK_PACKAGE': (str, str,
         """The name of the Android package to generate R.java for, like org.mozilla.gecko.
         """),
 
@@ -962,7 +961,7 @@
         """),
 
     'GENERATED_FILES': (StrictOrderingOnAppendListWithFlagsFactory({
-                'script': unicode,
+                'script': str,
                 'inputs': list }), list,
         """Generic generated files.
 
@@ -1107,7 +1106,7 @@
         """Like ``OBJDIR_FILES``, with preprocessing. Use sparingly.
         """),
 
-    'FINAL_LIBRARY': (unicode, unicode,
+    'FINAL_LIBRARY': (str, str,
         """Library in which the objects of the current directory will be linked.
 
         This variable contains the name of a library, defined elsewhere with
@@ -1158,7 +1157,7 @@
         """A list of python unit tests.
         """),
 
-    'HOST_LIBRARY_NAME': (unicode, unicode,
+    'HOST_LIBRARY_NAME': (str, str,
         """Name of target library generated when cross compiling.
         """),
 
@@ -1176,7 +1175,7 @@
         libraries that link into this library via FINAL_LIBRARY.
         """),
 
-    'LIBRARY_NAME': (unicode, unicode,
+    'LIBRARY_NAME': (str, str,
         """The code name of the library generated for a directory.
 
         By default STATIC_LIBRARY_NAME and SHARED_LIBRARY_NAME take this name.
@@ -1188,7 +1187,7 @@
         ``example/components/xpcomsample.lib`` on Windows.
         """),
 
-    'SHARED_LIBRARY_NAME': (unicode, unicode,
+    'SHARED_LIBRARY_NAME': (str, str,
         """The name of the static library generated for a directory, if it needs to
         differ from the library code name.
 
@@ -1202,7 +1201,7 @@
         Implies FORCE_SHARED_LIB.
         """),
 
-    'STATIC_LIBRARY_NAME': (unicode, unicode,
+    'STATIC_LIBRARY_NAME': (str, str,
         """The name of the static library generated for a directory, if it needs to
         differ from the library code name.
 
@@ -1238,37 +1237,37 @@
 
         This variable contains a list of system libaries to link against.
         """),
-    'RCFILE': (unicode, unicode,
+    'RCFILE': (str, str,
         """The program .rc file.
 
         This variable can only be used on Windows.
         """),
 
-    'RESFILE': (unicode, unicode,
+    'RESFILE': (str, str,
         """The program .res file.
 
         This variable can only be used on Windows.
         """),
 
-    'RCINCLUDE': (unicode, unicode,
+    'RCINCLUDE': (str, str,
         """The resource script file to be included in the default .res file.
 
         This variable can only be used on Windows.
         """),
 
-    'DEFFILE': (unicode, unicode,
+    'DEFFILE': (str, str,
         """The program .def (module definition) file.
 
         This variable can only be used on Windows.
         """),
 
-    'LD_VERSION_SCRIPT': (unicode, unicode,
+    'LD_VERSION_SCRIPT': (str, str,
         """The linker version script for shared libraries.
 
         This variable can only be used on Linux.
         """),
 
-    'SYMBOLS_FILE': (Path, unicode,
+    'SYMBOLS_FILE': (Path, str,
         """A file containing a list of symbols to export from a shared library.
 
         The given file contains a list of symbols to be exported, and is
@@ -1323,7 +1322,7 @@
         ``BIN_SUFFIX``, the name will remain unchanged.
         """),
 
-    'SONAME': (unicode, unicode,
+    'SONAME': (str, str,
         """The soname of the shared object currently being linked
 
         soname is the "logical name" of a shared object, often used to provide
@@ -1379,7 +1378,7 @@
         ``GENERATED_FILES``.
         """),
 
-    'PROGRAM' : (unicode, unicode,
+    'PROGRAM' : (str, str,
         """Compiled executable name.
 
         If the configuration token ``BIN_SUFFIX`` is set, its value will be
@@ -1387,7 +1386,7 @@
         ``BIN_SUFFIX``, ``PROGRAM`` will remain unchanged.
         """),
 
-    'HOST_PROGRAM' : (unicode, unicode,
+    'HOST_PROGRAM' : (str, str,
         """Compiled host executable name.
 
         If the configuration token ``HOST_BIN_SUFFIX`` is set, its value will be
@@ -1425,7 +1424,7 @@
         files.
         """),
 
-    'XPIDL_MODULE': (unicode, unicode,
+    'XPIDL_MODULE': (str, str,
         """XPCOM Interface Definition Module Name.
 
         This is the name of the ``.xpt`` file that is created by linking
@@ -1576,14 +1575,14 @@
         """),
 
     # The following variables are used to control the target of installed files.
-    'XPI_NAME': (unicode, unicode,
+    'XPI_NAME': (str, str,
         """The name of an extension XPI to generate.
 
         When this variable is present, the results of this directory will end up
         being packaged into an extension instead of the main dist/bin results.
         """),
 
-    'DIST_SUBDIR': (unicode, unicode,
+    'DIST_SUBDIR': (str, str,
         """The name of an alternate directory to install files to.
 
         When this variable is present, the results of this directory will end up
@@ -1591,7 +1590,7 @@
         otherwise be placed.
         """),
 
-    'FINAL_TARGET': (FinalTargetValue, unicode,
+    'FINAL_TARGET': (FinalTargetValue, str,
         """The name of the directory to install targets to.
 
         The directory is relative to the top of the object directory. The
@@ -1622,7 +1621,7 @@
 
     'GYP_DIRS': (StrictOrderingOnAppendListWithFlagsFactory({
             'variables': dict,
-            'input': unicode,
+            'input': str,
             'sandbox_vars': dict,
             'non_unified_sources': StrictOrderingOnAppendList,
         }), list,
@@ -1799,7 +1798,7 @@
 }
 
 # Sanity check: we don't want any variable above to have a list as storage type.
-for name, (storage_type, input_types, docs) in VARIABLES.items():
+for name, (storage_type, input_types, docs) in list(VARIABLES.items()):
     if storage_type == list:
         raise RuntimeError('%s has a "list" storage type. Use "List" instead.'
             % name)
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/data.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/data.py	(refactored)
@@ -15,7 +15,7 @@
 structures.
 """
 
-from __future__ import absolute_import, unicode_literals
+
 
 from mozbuild.util import StrictOrderingOnAppendList
 from mozpack.chrome.manifest import ManifestEntry
@@ -186,7 +186,7 @@
         self.defines = defines
 
     def get_defines(self):
-        for define, value in self.defines.iteritems():
+        for define, value in self.defines.items():
             if value is True:
                 yield('-D%s' % define)
             elif value is False:
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/emitter.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/emitter.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import itertools
 import logging
@@ -120,8 +120,8 @@
         # arguments. This gross hack works around the problem until we
         # rid ourselves of 2.6.
         self.info = {}
-        for k, v in mozinfo.info.items():
-            if isinstance(k, unicode):
+        for k, v in list(mozinfo.info.items()):
+            if isinstance(k, str):
                 k = k.encode('ascii')
             self.info[k] = v
 
@@ -197,7 +197,7 @@
 
     def _emit_libs_derived(self, contexts):
         # First do FINAL_LIBRARY linkage.
-        for lib in (l for libs in self._libs.values() for l in libs):
+        for lib in (l for libs in list(self._libs.values()) for l in libs):
             if not isinstance(lib, (StaticLibrary, RustLibrary)) or not lib.link_into:
                 continue
             if lib.link_into not in self._libs:
@@ -257,12 +257,12 @@
                         lib.link_into == outerlib.basename):
                     propagate_defines(lib, defines)
 
-        for lib in (l for libs in self._libs.values() for l in libs):
+        for lib in (l for libs in list(self._libs.values()) for l in libs):
             if isinstance(lib, Library):
                 propagate_defines(lib, lib.lib_defines)
             yield lib
 
-        for obj in self._binaries.values():
+        for obj in list(self._binaries.values()):
             yield obj
 
     LIBRARY_NAME_VAR = {
@@ -321,7 +321,7 @@
                             libs[key] = l
                         if key not in libs:
                             libs[key] = l
-                candidates = libs.values()
+                candidates = list(libs.values())
                 if force_static and not candidates:
                     if dir:
                         raise SandboxValidationError(
@@ -383,9 +383,9 @@
 
     def _verify_deps(self, context, crate_dir, crate_name, dependencies, description='Dependency'):
         """Verify that a crate's dependencies all specify local paths."""
-        for dep_crate_name, values in dependencies.iteritems():
+        for dep_crate_name, values in dependencies.items():
             # A simple version number.
-            if isinstance(values, (str, unicode)):
+            if isinstance(values, str):
                 raise SandboxValidationError(
                     '%s %s of crate %s does not list a path' % (description, dep_crate_name, crate_name),
                     context)
@@ -463,7 +463,7 @@
                      ' in [profile.%s] section') % (libname, profile_name),
                     context)
 
-        dependencies = set(config.get('dependencies', {}).iterkeys())
+        dependencies = set(config.get('dependencies', {}).keys())
 
         return RustLibrary(context, libname, cargo_file, crate_type,
                            dependencies, **static_args)
@@ -738,7 +738,7 @@
         assert not gen_sources['UNIFIED_SOURCES']
 
         no_pgo = context.get('NO_PGO')
-        no_pgo_sources = [f for f, flags in all_flags.iteritems()
+        no_pgo_sources = [f for f, flags in all_flags.items()
                           if flags.no_pgo]
         if no_pgo:
             if no_pgo_sources:
@@ -765,7 +765,7 @@
 
         # The inverse of the above, mapping suffixes to their canonical suffix.
         canonicalized_suffix_map = {}
-        for suffix, alternatives in suffix_map.iteritems():
+        for suffix, alternatives in suffix_map.items():
             alternatives.add(suffix)
             for a in alternatives:
                 canonicalized_suffix_map[a] = suffix
@@ -786,7 +786,7 @@
         # a directory with mixed C and C++ source, but it's not that important.
         cxx_sources = defaultdict(bool)
 
-        for variable, (klass, gen_klass, suffixes) in varmap.items():
+        for variable, (klass, gen_klass, suffixes) in list(varmap.items()):
             allowed_suffixes = set().union(*[suffix_map[s] for s in suffixes])
 
             # First ensure that we haven't been given filetypes that we don't
@@ -812,7 +812,7 @@
                     obj = cls(*arglist)
                     yield obj
 
-        for f, flags in all_flags.iteritems():
+        for f, flags in all_flags.items():
             if flags.flags:
                 ext = mozpath.splitext(f)[1]
                 yield PerSourceFlag(context, f, flags.flags)
@@ -958,7 +958,7 @@
         for obj in self._handle_linkables(context, passthru, generated_files):
             yield obj
 
-        generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in self._binaries.keys()])
+        generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in list(self._binaries.keys())])
 
         components = []
         for var, cls in (
@@ -1055,10 +1055,10 @@
         for obj in self._process_jar_manifests(context):
             yield obj
 
-        for name, jar in context.get('JAVA_JAR_TARGETS', {}).items():
+        for name, jar in list(context.get('JAVA_JAR_TARGETS', {}).items()):
             yield ContextWrapped(context, jar)
 
-        for name, data in context.get('ANDROID_ECLIPSE_PROJECT_TARGETS', {}).items():
+        for name, data in list(context.get('ANDROID_ECLIPSE_PROJECT_TARGETS', {}).items()):
             yield ContextWrapped(context, data)
 
         if context.get('USE_YASM') is True:
@@ -1127,7 +1127,7 @@
             script = mozpath.join(mozpath.dirname(mozpath.dirname(__file__)),
                                   'action', 'process_define_files.py')
             yield GeneratedFile(context, script, 'process_define_file',
-                                unicode(path),
+                                str(path),
                                 [Path(context, path + '.in')])
 
         generated_files = context.get('GENERATED_FILES')
@@ -1170,7 +1170,7 @@
             yield GeneratedFile(context, script, method, outputs, inputs)
 
     def _process_test_manifests(self, context):
-        for prefix, info in TEST_MANIFESTS.items():
+        for prefix, info in list(TEST_MANIFESTS.items()):
             for path, manifest in context.get('%s_MANIFESTS' % prefix, []):
                 for obj in self._process_test_manifest(context, info, path, manifest):
                     yield obj
@@ -1261,7 +1261,7 @@
 
                 process_support_files(test)
 
-            for path, m_defaults in mpmanifest.manifest_defaults.items():
+            for path, m_defaults in list(mpmanifest.manifest_defaults.items()):
                 process_support_files(m_defaults)
 
             # We also copy manifests into the output directory,
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/gyp_reader.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/gyp_reader.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 import gyp
 import sys
@@ -69,7 +69,7 @@
 
 
 def encode(value):
-    if isinstance(value, unicode):
+    if isinstance(value, str):
         return value.encode('utf-8')
     return value
 
@@ -87,7 +87,7 @@
     # gyp expects plain str instead of unicode. The frontend code gives us
     # unicode strings, so convert them.
     path = encode(path)
-    str_vars = dict((name, encode(value)) for name, value in vars.items())
+    str_vars = dict((name, encode(value)) for name, value in list(vars.items()))
 
     params = {
         b'parallel': False,
@@ -222,7 +222,7 @@
                         if not f:
                             continue
                         # the result may be a string or a list.
-                        if isinstance(f, types.StringTypes):
+                        if isinstance(f, (str,)):
                             context[var].append(f)
                         else:
                             context[var].extend(f)
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/mach_commands.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/mach_commands.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 from collections import defaultdict
 import os
@@ -105,13 +105,13 @@
         """
         components = defaultdict(set)
         try:
-            for p, m in self._get_files_info(paths, rev=rev).items():
+            for p, m in list(self._get_files_info(paths, rev=rev).items()):
                 components[m.get('BUG_COMPONENT')].add(p)
         except InvalidPathException as e:
             print(e.message)
             return 1
 
-        for component, files in sorted(components.items(), key=lambda x: (x is None, x)):
+        for component, files in sorted(list(components.items()), key=lambda x: (x is None, x)):
             print('%s :: %s' % (component.product, component.component) if component else 'UNKNOWN')
             for f in sorted(files):
                 print('  %s' % f)
@@ -139,7 +139,7 @@
                      help='Paths whose data to query')
     def file_info_test_deps(self, paths, rev=None):
         try:
-            for p, m in self._get_files_info(paths, rev=rev).items():
+            for p, m in list(self._get_files_info(paths, rev=rev).items()):
                 print('%s:' % mozpath.relpath(p, self.topsrcdir))
                 if m.test_files:
                     print('\tTest file patterns:')
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py	(refactored)
@@ -16,7 +16,7 @@
 It does this by examining specific variables populated during execution.
 """
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import ast
 import inspect
@@ -80,11 +80,12 @@
 )
 
 from mozbuild.base import ExecutionSummary
+from functools import reduce
 
 
 if sys.version_info.major == 2:
-    text_type = unicode
-    type_type = types.TypeType
+    text_type = str
+    type_type = type
 else:
     text_type = str
     type_type = type
@@ -126,7 +127,7 @@
             b'JS_STANDALONE': b'1',
         })
         udict = {}
-        for k, v in self.substs.items():
+        for k, v in list(self.substs.items()):
             if isinstance(v, str):
                 udict[k.decode('utf-8')] = v.decode('utf-8')
             else:
@@ -338,7 +339,7 @@
             raise Exception('`template` is a function decorator. You must '
                 'use it as `@template` preceding a function declaration.')
 
-        name = func.func_name
+        name = func.__name__
 
         if name in self.templates:
             raise KeyError(
@@ -417,7 +418,7 @@
             klass = self._context.__class__
             self._context.__class__ = TemplateContext
             # The sandbox will do all the necessary checks for these merges.
-            for key, value in context.items():
+            for key, value in list(context.items()):
                 if isinstance(value, dict):
                     self[key].update(value)
                 elif isinstance(value, (list, HierarchicalStringList)):
@@ -434,10 +435,10 @@
 
 class TemplateFunction(object):
     def __init__(self, func, sandbox):
-        self.path = func.func_code.co_filename
-        self.name = func.func_name
-
-        code = func.func_code
+        self.path = func.__code__.co_filename
+        self.name = func.__name__
+
+        code = func.__code__
         firstlineno = code.co_firstlineno
         lines = sandbox._current_source.splitlines(True)
         lines = inspect.getblock(lines[firstlineno - 1:])
@@ -476,8 +477,8 @@
             compile(func_ast, self.path, 'exec'),
             glob,
             self.name,
-            func.func_defaults,
-            func.func_closure,
+            func.__defaults__,
+            func.__closure__,
         )
         func()
 
@@ -491,11 +492,11 @@
             '__builtins__': sandbox._builtins
         }
         func = types.FunctionType(
-            self._func.func_code,
+            self._func.__code__,
             glob,
             self.name,
-            self._func.func_defaults,
-            self._func.func_closure
+            self._func.__defaults__,
+            self._func.__closure__
         )
         sandbox.exec_function(func, args, kwargs, self.path,
                               becomes_current_path=False)
@@ -511,7 +512,7 @@
         def visit_Str(self, node):
             # String nodes we got from the AST parser are str, but we want
             # unicode literals everywhere, so transform them.
-            node.s = unicode(node.s)
+            node.s = str(node.s)
             return node
 
         def visit_Name(self, node):
@@ -644,7 +645,7 @@
 
             for l in traceback.format_exception(type(self.other), self.other,
                 self.trace):
-                s.write(unicode(l))
+                s.write(str(l))
 
         return s.getvalue()
 
@@ -794,7 +795,7 @@
             s.write('    %s\n' % inner.args[2])
             s.write('\n')
             close_matches = difflib.get_close_matches(inner.args[2],
-                                                      VARIABLES.keys(), 2)
+                                                      list(VARIABLES.keys()), 2)
             if close_matches:
                 s.write('Maybe you meant %s?\n' % ' or '.join(close_matches))
                 s.write('\n')
@@ -1196,7 +1197,7 @@
 
                 recurse_info[d][key] = dict(sandbox.metadata[key])
 
-        for path, child_metadata in recurse_info.items():
+        for path, child_metadata in list(recurse_info.items()):
             child_path = path.join('moz.build').full_path
 
             # Ensure we don't break out of the topsrcdir. We don't do realpath
@@ -1288,7 +1289,7 @@
         # There is room to improve this code (and the code in
         # _find_relevant_mozbuilds) to better handle multiple files in the same
         # directory. Bug 1136966 tracks.
-        for path, mbpaths in relevants.items():
+        for path, mbpaths in list(relevants.items()):
             path_mozbuilds[path] = [mozpath.join(topsrcdir, p) for p in mbpaths]
 
             for i, mbpath in enumerate(mbpaths[0:-1]):
@@ -1325,7 +1326,7 @@
             all_contexts.append(context)
 
         result = {}
-        for path, paths in path_mozbuilds.items():
+        for path, paths in list(path_mozbuilds.items()):
             result[path] = reduce(lambda x, y: x + y, (contexts[p] for p in paths), [])
 
         return result, all_contexts
@@ -1352,7 +1353,7 @@
 
         r = {}
 
-        for path, ctxs in paths.items():
+        for path, ctxs in list(paths.items()):
             flags = Files(Context())
 
             for ctx in ctxs:
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/sandbox.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/sandbox.py	(refactored)
@@ -17,7 +17,7 @@
 user-friendly error messages in the case of errors.
 """
 
-from __future__ import absolute_import, unicode_literals
+
 
 import os
 import sys
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/common.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/common.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 from mach.logging import LoggingManager
 
@@ -36,7 +36,7 @@
         }, **extra_substs)
 
         self.substs_unicode = ReadOnlyDict({k.decode('utf-8'): v.decode('utf-8',
-            'replace') for k, v in self.substs.items()})
+            'replace') for k, v in list(self.substs.items())})
 
         self.defines = self.substs
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_base.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_base.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import json
 import os
@@ -12,7 +12,7 @@
 import tempfile
 import unittest
 
-from cStringIO import StringIO
+from io import StringIO
 from mozfile.mozfile import NamedTemporaryFile
 
 from mozunit import main
@@ -93,7 +93,7 @@
             mozconfig = os.path.join(d, 'mozconfig')
             with open(mozconfig, 'wt') as fh:
                 fh.write('mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/foo/@CONFIG_GUESS@')
-            print('Wrote mozconfig %s' % mozconfig)
+            print(('Wrote mozconfig %s' % mozconfig))
 
             topobjdir = os.path.join(d, 'foo', guess)
             os.makedirs(topobjdir)
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_containers.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_containers.py	(refactored)
@@ -152,7 +152,7 @@
 
         self.assertEqual(test['foo'], 1)
 
-        self.assertEqual(test.keys(), ['foo', 'bar' ])
+        self.assertEqual(list(test.keys()), ['foo', 'bar' ])
 
     def test_defaults(self):
         test = OrderedDefaultDict(bool, {'foo': 1 })
@@ -161,7 +161,7 @@
 
         self.assertEqual(test['qux'], False)
 
-        self.assertEqual(test.keys(), ['foo', 'qux' ])
+        self.assertEqual(list(test.keys()), ['foo', 'qux' ])
 
 
 class TestKeyedDefaultDict(unittest.TestCase):
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_dotproperties.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_dotproperties.py	(refactored)
@@ -1,11 +1,11 @@
 # -*- coding: utf-8 -*-
 
-from __future__ import unicode_literals
+
 
 import os
 import unittest
 
-from StringIO import StringIO
+from io import StringIO
 
 import mozpack.path as mozpath
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_expression.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_expression.py	(refactored)
@@ -25,8 +25,8 @@
 
   def test_in(self):
     """test 'var in context' to not fall for fallback"""
-    self.assert_('FAIL' in self.c)
-    self.assert_('PASS' not in self.c)
+    self.assertTrue('FAIL' in self.c)
+    self.assertTrue('PASS' not in self.c)
 
 class TestExpression(unittest.TestCase):
   """
@@ -48,16 +48,16 @@
 
   def test_not(self):
     """Test for the ! operator"""
-    self.assert_(Expression('!0').evaluate(self.c))
-    self.assert_(not Expression('!1').evaluate(self.c))
+    self.assertTrue(Expression('!0').evaluate(self.c))
+    self.assertTrue(not Expression('!1').evaluate(self.c))
 
   def test_equals(self):
     """ Test for the == operator"""
-    self.assert_(Expression('FAIL == PASS').evaluate(self.c))
+    self.assertTrue(Expression('FAIL == PASS').evaluate(self.c))
 
   def test_notequals(self):
     """ Test for the != operator"""
-    self.assert_(Expression('FAIL != 1').evaluate(self.c))
+    self.assertTrue(Expression('FAIL != 1').evaluate(self.c))
 
   def test_logical_and(self):
     """ Test for the && operator"""
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_jarmaker.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_jarmaker.py	(refactored)
@@ -2,14 +2,14 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import print_function
+
 import unittest
 
 import os, sys, os.path, time, inspect
 from filecmp import dircmp
 from tempfile import mkdtemp
 from shutil import rmtree, copy2
-from StringIO import StringIO
+from io import StringIO
 from zipfile import ZipFile
 import mozunit
 
@@ -117,12 +117,12 @@
     """Helper to report rich results on difference between two directories.
     """
     def _fillDiff(self, dc, rv, basepath="{0}"):
-        rv['right_only'] += map(lambda l: basepath.format(l), dc.right_only)
-        rv['left_only'] += map(lambda l: basepath.format(l), dc.left_only)
-        rv['diff_files'] += map(lambda l: basepath.format(l), dc.diff_files)
-        rv['funny'] += map(lambda l: basepath.format(l), dc.common_funny)
-        rv['funny'] += map(lambda l: basepath.format(l), dc.funny_files)
-        for subdir, _dc in dc.subdirs.iteritems():
+        rv['right_only'] += [basepath.format(l) for l in dc.right_only]
+        rv['left_only'] += [basepath.format(l) for l in dc.left_only]
+        rv['diff_files'] += [basepath.format(l) for l in dc.diff_files]
+        rv['funny'] += [basepath.format(l) for l in dc.common_funny]
+        rv['funny'] += [basepath.format(l) for l in dc.funny_files]
+        for subdir, _dc in dc.subdirs.items():
             self._fillDiff(_dc, rv, basepath.format(subdir + "/{0}"))
     def allResults(self, left, right):
         rv = {'right_only':[], 'left_only':[],
@@ -295,7 +295,7 @@
             ('hoge', 'foo', '2'): ('qux', 'foo', '2'),
             ('hoge', 'baz'): ('qux', 'baz'),
         }
-        for dest, src in expected_symlinks.iteritems():
+        for dest, src in expected_symlinks.items():
             srcpath = os.path.join(self.srcdir, *src)
             destpath = os.path.join(self.builddir, 'chrome', 'test', 'dir',
                                     *dest)
@@ -317,7 +317,7 @@
     def test_en_US(self):
         jm = self.jm
         jm.makeJar(self.fake_empty_file, '/NO_OUTPUT_REQUIRED')
-        self.assertEquals(jm.localedirs,
+        self.assertEqual(jm.localedirs,
                           [
                             os.path.join(os.path.abspath('/TOPSOURCEDIR'),
                                          'browser/locales', 'en-US')
@@ -326,13 +326,13 @@
         jm = self.jm
         jm.l10nbase = '/L10N_BASE'
         jm.makeJar(self.fake_empty_file, '/NO_OUTPUT_REQUIRED')
-        self.assertEquals(jm.localedirs, [os.path.join('/L10N_BASE', 'browser')])
+        self.assertEqual(jm.localedirs, [os.path.join('/L10N_BASE', 'browser')])
     def test_l10n_merge(self):
         jm = self.jm
         jm.l10nbase = '/L10N_BASE'
         jm.l10nmerge = '/L10N_MERGE'
         jm.makeJar(self.fake_empty_file, '/NO_OUTPUT_REQUIRED')
-        self.assertEquals(jm.localedirs,
+        self.assertEqual(jm.localedirs,
                           [os.path.join('/L10N_MERGE', 'browser'),
                            os.path.join('/L10N_BASE', 'browser'),
                            os.path.join(os.path.abspath('/TOPSOURCEDIR'),
@@ -346,7 +346,7 @@
 ''')
         jarcontents.name = 'override.mn'
         jm.makeJar(jarcontents, '/NO_OUTPUT_REQUIRED')
-        self.assertEquals(jm.localedirs,
+        self.assertEqual(jm.localedirs,
                           [
                             os.path.join(os.path.abspath('/TOPSOURCEDIR'),
                                          'dom/locales', 'en-US')
@@ -360,7 +360,7 @@
 ''')
         jarcontents.name = 'override.mn'
         jm.makeJar(jarcontents, '/NO_OUTPUT_REQUIRED')
-        self.assertEquals(jm.localedirs, [os.path.join('/L10N_BASE', 'dom')])
+        self.assertEqual(jm.localedirs, [os.path.join('/L10N_BASE', 'dom')])
 
 
 if __name__ == '__main__':
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_line_endings.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_line_endings.py	(refactored)
@@ -1,6 +1,6 @@
 import unittest
 
-from StringIO import StringIO
+from io import StringIO
 import os
 import sys
 import os.path
@@ -30,17 +30,17 @@
   def testMac(self):
     self.createFile(['\x0D']*3)
     self.pp.do_include(self.tempnam)
-    self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
+    self.assertEqual(self.pp.out.getvalue(), 'a\nb\nc\n')
 
   def testUnix(self):
     self.createFile(['\x0A']*3)
     self.pp.do_include(self.tempnam)
-    self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
+    self.assertEqual(self.pp.out.getvalue(), 'a\nb\nc\n')
 
   def testWindows(self):
     self.createFile(['\x0D\x0A']*3)
     self.pp.do_include(self.tempnam)
-    self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
+    self.assertEqual(self.pp.out.getvalue(), 'a\nb\nc\n')
 
 if __name__ == '__main__':
   mozunit.main()
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_makeutil.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_makeutil.py	(refactored)
@@ -11,7 +11,7 @@
 from mozunit import main
 import os
 import unittest
-from StringIO import StringIO
+from io import StringIO
 
 
 class TestMakefile(unittest.TestCase):
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_mozconfig.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_mozconfig.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import unittest
@@ -480,9 +480,9 @@
 
             self.assertTrue(e.exception.message.startswith(
                 'Evaluation of your mozconfig exited with an error'))
-            self.assertEquals(e.exception.path,
+            self.assertEqual(e.exception.path,
                 mozconfig.name.replace(os.sep, '/'))
-            self.assertEquals(e.exception.output, ['hello world'])
+            self.assertEqual(e.exception.output, ['hello world'])
 
 
 if __name__ == '__main__':
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_mozinfo.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_mozinfo.py	(refactored)
@@ -8,7 +8,7 @@
 import tempfile
 import unittest
 
-from StringIO import StringIO
+from io import StringIO
 
 import mozunit
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_preprocessor.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_preprocessor.py	(refactored)
@@ -4,7 +4,7 @@
 
 import unittest
 
-from StringIO import StringIO
+from io import StringIO
 import os
 import shutil
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_pythonutil.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_pythonutil.py	(refactored)
@@ -12,7 +12,7 @@
     def test_iter_modules_in_path(self):
         mozbuild_path = os.path.normcase(os.path.dirname(os.path.dirname(__file__)))
         paths = list(iter_modules_in_path(mozbuild_path))
-        self.assertEquals(sorted(paths), [
+        self.assertEqual(sorted(paths), [
             os.path.join(os.path.abspath(mozbuild_path), '__init__.py'),
             os.path.join(os.path.abspath(mozbuild_path), 'pythonutil.py'),
             os.path.join(os.path.abspath(mozbuild_path), 'test', 'test_pythonutil.py'),
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/test_util.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/test_util.py	(refactored)
@@ -3,7 +3,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import itertools
 import hashlib
@@ -110,7 +110,7 @@
             '''
             def __call__(self, name, mode):
                 if 'w' in mode:
-                    raise Exception, 'Unexpected open with write mode'
+                    raise Exception('Unexpected open with write mode')
                 return MockedOpen.__call__(self, name, mode)
 
         with MyMockedOpen({'file': 'content'}):
@@ -432,7 +432,7 @@
         self.assertEqual(len(l), 0)
         original = ['a', 'b', 'c']
         l = ListWithAction(['a', 'b', 'c'], action=self.action)
-        expected = map(self.action, original)
+        expected = list(map(self.action, original))
         self.assertSameList(expected, l)
 
         with self.assertRaises(ValueError):
@@ -445,7 +445,7 @@
         l = ListWithAction(action=self.action)
         original = ['a', 'b']
         l.extend(original)
-        expected = map(self.action, original)
+        expected = list(map(self.action, original))
         self.assertSameList(expected, l)
 
         with self.assertRaises(ValueError):
@@ -455,7 +455,7 @@
         l = ListWithAction(action=self.action)
         original = ['a', 'b']
         l[:] = original
-        expected = map(self.action, original)
+        expected = list(map(self.action, original))
         self.assertSameList(expected, l)
 
         with self.assertRaises(ValueError):
@@ -465,7 +465,7 @@
         l = ListWithAction(action=self.action)
         original = ['a', 'b']
         l2 = l + original
-        expected = map(self.action, original)
+        expected = list(map(self.action, original))
         self.assertSameList(expected, l2)
 
         with self.assertRaises(ValueError):
@@ -475,7 +475,7 @@
         l = ListWithAction(action=self.action)
         original = ['a', 'b']
         l += original
-        expected = map(self.action, original)
+        expected = list(map(self.action, original))
         self.assertSameList(expected, l)
 
         with self.assertRaises(ValueError):
@@ -524,7 +524,7 @@
 
     def test_strict_ordering_on_append_list_with_flags_factory_extend(self):
         FooList = StrictOrderingOnAppendListWithFlagsFactory({
-            'foo': bool, 'bar': unicode
+            'foo': bool, 'bar': str
         })
         foo = FooList(['a', 'b', 'c'])
         foo['a'].foo = True
@@ -532,7 +532,7 @@
 
         # Don't allow extending lists with different flag definitions.
         BarList = StrictOrderingOnAppendListWithFlagsFactory({
-            'foo': unicode, 'baz': bool
+            'foo': str, 'baz': bool
         })
         bar = BarList(['d', 'e', 'f'])
         bar['d'].foo = 'foo'
@@ -752,9 +752,9 @@
 
 class TypedTestStrictOrderingOnAppendList(unittest.TestCase):
     def test_init(self):
-        class Unicode(unicode):
+        class Unicode(str):
             def __init__(self, other):
-                if not isinstance(other, unicode):
+                if not isinstance(other, str):
                     raise ValueError()
                 super(Unicode, self).__init__(other)
 
@@ -776,14 +776,14 @@
 
 class TestTypedNamedTuple(unittest.TestCase):
     def test_simple(self):
-        FooBar = TypedNamedTuple('FooBar', [('foo', unicode), ('bar', int)])
+        FooBar = TypedNamedTuple('FooBar', [('foo', str), ('bar', int)])
 
         t = FooBar(foo='foo', bar=2)
-        self.assertEquals(type(t), FooBar)
-        self.assertEquals(t.foo, 'foo')
-        self.assertEquals(t.bar, 2)
-        self.assertEquals(t[0], 'foo')
-        self.assertEquals(t[1], 2)
+        self.assertEqual(type(t), FooBar)
+        self.assertEqual(t.foo, 'foo')
+        self.assertEqual(t.bar, 2)
+        self.assertEqual(t[0], 'foo')
+        self.assertEqual(t[1], 2)
 
         FooBar('foo', 2)
 
@@ -796,7 +796,7 @@
         # arguments.
         t1 = ('foo', 3)
         t2 = FooBar(t1)
-        self.assertEquals(type(t2), FooBar)
+        self.assertEqual(type(t2), FooBar)
         self.assertEqual(FooBar(t1), FooBar('foo', 3))
 
 
@@ -871,18 +871,18 @@
         CompilerType = EnumString.subclass('msvc', 'gcc', 'clang', 'clang-cl')
 
         type = CompilerType('msvc')
-        self.assertEquals(type, 'msvc')
-        self.assertNotEquals(type, 'gcc')
-        self.assertNotEquals(type, 'clang')
-        self.assertNotEquals(type, 'clang-cl')
+        self.assertEqual(type, 'msvc')
+        self.assertNotEqual(type, 'gcc')
+        self.assertNotEqual(type, 'clang')
+        self.assertNotEqual(type, 'clang-cl')
         self.assertIn(type, ('msvc', 'clang-cl'))
         self.assertNotIn(type, ('gcc', 'clang'))
 
         with self.assertRaises(EnumStringComparisonError):
-            self.assertEquals(type, 'foo')
+            self.assertEqual(type, 'foo')
 
         with self.assertRaises(EnumStringComparisonError):
-            self.assertNotEquals(type, 'foo')
+            self.assertNotEqual(type, 'foo')
 
         with self.assertRaises(EnumStringComparisonError):
             self.assertIn(type, ('foo', 'gcc'))
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_buildlist.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_buildlist.py	(refactored)
@@ -38,11 +38,11 @@
     lines = [line.rstrip() for line in f.readlines()]
     f.close()
     for line in lines:
-      self.assert_(len(l) > 0,
+      self.assertTrue(len(l) > 0,
                    "ran out of expected lines! (expected '{0}', got '{1}')"
                    .format(l, lines))
       self.assertEqual(line, l.pop(0))
-    self.assert_(len(l) == 0, 
+    self.assertTrue(len(l) == 0, 
                  "not enough lines in file! (expected '{0}',"
                  " got '{1}'".format(l, lines))
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_generate_browsersearch.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_generate_browsersearch.py	(refactored)
@@ -3,7 +3,7 @@
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
-from __future__ import unicode_literals
+
 
 import json
 import os
@@ -43,8 +43,8 @@
 
     def test_valid_unicode(self):
         o = self._test_one('valid-zh-CN')
-        self.assertEquals(o['default'], '百度')
-        self.assertEquals(o['engines'], ['百度', 'Google'])
+        self.assertEqual(o['default'], '百度')
+        self.assertEqual(o['engines'], ['百度', 'Google'])
 
     def test_invalid_unicode(self):
         with self.assertRaises(UnicodeDecodeError):
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_package_fennec_apk.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/action/test_package_fennec_apk.py	(refactored)
@@ -3,7 +3,7 @@
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
-from __future__ import unicode_literals
+
 
 import os
 import unittest
@@ -41,14 +41,14 @@
                          root_files=[data('root_file.txt')])
 
         # omni.ja ends up in assets/omni.ja.
-        self.assertEquals(jarrer['assets/omni.ja'].open().read().strip(), 'omni.ja')
+        self.assertEqual(jarrer['assets/omni.ja'].open().read().strip(), 'omni.ja')
 
         # Everything else is in place.
         for name in ('classes.dex',
                      'assets/asset.txt',
                      'lib/lib.txt',
                      'root_file.txt'):
-            self.assertEquals(jarrer[name].open().read().strip(), name)
+            self.assertEqual(jarrer[name].open().read().strip(), name)
 
     def test_inputs(self):
         # Language repacks take updated resources from an ap_ and pack them
@@ -57,8 +57,8 @@
         # overrides the first.
         jarrer = package(inputs=[data('input2.apk'), data('input1.ap_')])
 
-        files1 = JarReader(data('input1.ap_')).entries.keys()
-        files2 = JarReader(data('input2.apk')).entries.keys()
+        files1 = list(JarReader(data('input1.ap_')).entries.keys())
+        files2 = list(JarReader(data('input2.apk')).entries.keys())
         for name in files2:
             self.assertTrue(name in files1 or
                             jarrer[name].open().read().startswith('input2/'))
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/common.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/common.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import unittest
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_build.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_build.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals, print_function
+
 
 import buildconfig
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_configenvironment.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_configenvironment.py	(refactored)
@@ -3,7 +3,7 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os, posixpath
-from StringIO import StringIO
+from io import StringIO
 import unittest
 from mozunit import main, MockedOpen
 
@@ -29,7 +29,7 @@
             self.substs = ReadOnlyDict(d)
 
             d = dict(self.substs_unicode)
-            d[u'top_srcdir'] = top_srcdir.decode('utf-8')
+            d['top_srcdir'] = top_srcdir.decode('utf-8')
             self.substs_unicode = ReadOnlyDict(d)
 
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_recursivemake.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_recursivemake.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
-
-import cPickle as pickle
+
+
+import pickle as pickle
 import json
 import os
 import unittest
@@ -331,7 +331,7 @@
             ],
         }
 
-        for var, val in expected.items():
+        for var, val in list(expected.items()):
             # print("test_variable_passthru[%s]" % (var))
             found = [str for str in lines if str.startswith(var)]
             self.assertEqual(found, val)
@@ -370,7 +370,7 @@
             ],
         }
 
-        for var, val in expected.items():
+        for var, val in list(expected.items()):
             found = [str for str in lines if str.startswith(var)]
             self.assertEqual(found, val)
 
@@ -544,7 +544,7 @@
 
         # This is not the most robust test in the world, but it gets the job
         # done.
-        entries = [e for e in m._dests.keys() if '**' in e]
+        entries = [e for e in list(m._dests.keys()) if '**' in e]
         self.assertEqual(len(entries), 1)
         self.assertIn('support/**', entries[0])
 
@@ -562,7 +562,7 @@
                          set(['child/test_sub.js',
                               'child/data/**',
                               'child/another-file.sjs']))
-        for key in test_installs.keys():
+        for key in list(test_installs.keys()):
             self.assertIn(key, test_installs)
 
         test_files_manifest = mozpath.join(env.topobjdir,
@@ -576,7 +576,7 @@
         # Then, synthesize one from the test-installs.pkl file. This should
         # allow us to re-create a subset of the above.
         synthesized_manifest = InstallManifest()
-        for item, installs in test_installs.items():
+        for item, installs in list(test_installs.items()):
             for install_info in installs:
                 if len(install_info) == 3:
                     synthesized_manifest.add_pattern_symlink(*install_info)
@@ -584,7 +584,7 @@
                     synthesized_manifest.add_symlink(*install_info)
 
         self.assertEqual(len(synthesized_manifest), 3)
-        for item, info in synthesized_manifest._dests.items():
+        for item, info in list(synthesized_manifest._dests.items()):
             self.assertIn(item, m)
             self.assertEqual(info, m._dests[item])
 
@@ -758,7 +758,7 @@
         expected[mozpath.join(env.topobjdir, 'final-target')] = [
             'FINAL_TARGET = $(DEPTH)/random-final-target'
         ]
-        for key, expected_rules in expected.iteritems():
+        for key, expected_rules in expected.items():
             backend_path = mozpath.join(key, 'backend.mk')
             lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
             found = [str for str in lines if
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_visualstudio.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/backend/test_visualstudio.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 from xml.dom.minidom import parse
 import os
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/common.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/common.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import copy
 import errno
@@ -16,7 +16,7 @@
 from mozbuild.util import ReadOnlyNamespace
 from mozpack import path as mozpath
 
-from StringIO import StringIO
+from io import StringIO
 from which import WhichError
 
 from buildconfig import (
@@ -78,10 +78,10 @@
         self._search_path = environ.get('PATH', '').split(os.pathsep)
 
         self._subprocess_paths = {
-            mozpath.abspath(k): v for k, v in paths.iteritems() if v
+            mozpath.abspath(k): v for k, v in paths.items() if v
         }
 
-        paths = paths.keys()
+        paths = list(paths.keys())
 
         environ = dict(environ)
         if 'CONFIG_SHELL' not in environ:
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/lint.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/lint.py	(refactored)
@@ -2,11 +2,11 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import os
 import unittest
-from StringIO import StringIO
+from io import StringIO
 from mozunit import main
 from buildconfig import (
     topobjdir,
@@ -42,9 +42,7 @@
         return type.__new__(mcs, name, bases, attrs)
 
 
-class Lint(unittest.TestCase):
-    __metaclass__ = LintMeta
-
+class Lint(unittest.TestCase, metaclass=LintMeta):
     def setUp(self):
         self._curdir = os.getcwd()
         os.chdir(topobjdir)
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_checks_configure.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_checks_configure.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
-
-from StringIO import StringIO
+
+
+from io import StringIO
 import os
 import sys
 import textwrap
@@ -447,7 +447,7 @@
             checking for a... %s
         ''' % self.OTHER_A))
 
-        dirs = map(mozpath.dirname, (self.OTHER_A, self.KNOWN_A))
+        dirs = list(map(mozpath.dirname, (self.OTHER_A, self.KNOWN_A)))
         config, out, status = self.get_result(textwrap.dedent('''\
             check_prog("A", ("known-a",), paths=["%s"])
         ''' % os.pathsep.join(dirs)))
@@ -457,7 +457,7 @@
             checking for a... %s
         ''' % self.OTHER_A))
 
-        dirs = map(mozpath.dirname, (self.KNOWN_A, self.KNOWN_B))
+        dirs = list(map(mozpath.dirname, (self.KNOWN_A, self.KNOWN_B)))
         config, out, status = self.get_result(textwrap.dedent('''\
             check_prog("A", ("known-a",), paths=["%s", "%s"])
         ''' % (os.pathsep.join(dirs), self.OTHER_A)))
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_compile_checks.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_compile_checks.py	(refactored)
@@ -2,14 +2,14 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import os
 import textwrap
 import unittest
 import mozpack.path as mozpath
 
-from StringIO import StringIO
+from io import StringIO
 
 from buildconfig import topsrcdir
 from common import ConfigureTestSandbox
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_configure.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_configure.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
-
-from StringIO import StringIO
+
+
+from io import StringIO
 import os
 import sys
 import textwrap
@@ -43,7 +43,7 @@
 
         if '--help' in options:
             return out.getvalue(), config
-        self.assertEquals('', out.getvalue())
+        self.assertEqual('', out.getvalue())
         return config
 
     def moz_configure(self, source):
@@ -55,7 +55,7 @@
     def test_defaults(self):
         config = self.get_config()
         self.maxDiff = None
-        self.assertEquals({
+        self.assertEqual({
             'CHOICES': NegativeOptionValue(),
             'DEFAULTED': PositiveOptionValue(('not-simple',)),
             'IS_GCC': NegativeOptionValue(),
@@ -71,9 +71,9 @@
     def test_help(self):
         help, config = self.get_config(['--help'], prog='configure')
 
-        self.assertEquals({}, config)
+        self.assertEqual({}, config)
         self.maxDiff = None
-        self.assertEquals(
+        self.assertEqual(
             'Usage: configure [options]\n'
             '\n'
             'Options: [defaults in brackets after descriptions]\n'
@@ -109,7 +109,7 @@
         ):
             self.assertNotIn('ENABLED_SIMPLE', config)
             self.assertIn('SIMPLE', config)
-            self.assertEquals(NegativeOptionValue(), config['SIMPLE'])
+            self.assertEqual(NegativeOptionValue(), config['SIMPLE'])
 
         for config in (
                 self.get_config(['--enable-simple']),
@@ -117,7 +117,7 @@
         ):
             self.assertIn('ENABLED_SIMPLE', config)
             self.assertIn('SIMPLE', config)
-            self.assertEquals(PositiveOptionValue(), config['SIMPLE'])
+            self.assertEqual(PositiveOptionValue(), config['SIMPLE'])
             self.assertIs(config['SIMPLE'], config['ENABLED_SIMPLE'])
 
         # --enable-simple doesn't take values.
@@ -135,7 +135,7 @@
                                 env={'MOZ_WITH_ENV': '1'}),
         ):
             self.assertIn('WITH_ENV', config)
-            self.assertEquals(NegativeOptionValue(), config['WITH_ENV'])
+            self.assertEqual(NegativeOptionValue(), config['WITH_ENV'])
 
         for config in (
                 self.get_config(['--enable-with-env']),
@@ -145,7 +145,7 @@
                                 env={'MOZ_WITH_ENV': ''}),
         ):
             self.assertIn('WITH_ENV', config)
-            self.assertEquals(PositiveOptionValue(), config['WITH_ENV'])
+            self.assertEqual(PositiveOptionValue(), config['WITH_ENV'])
 
         with self.assertRaises(InvalidOptionError):
             self.get_config(['--enable-with-env=value'])
@@ -160,23 +160,23 @@
             self.get_config(['--enable-values', '--disable-values']),
         ):
             self.assertIn(name, config)
-            self.assertEquals(NegativeOptionValue(), config[name])
+            self.assertEqual(NegativeOptionValue(), config[name])
 
         for config in (
             self.get_config(['--enable-values']),
             self.get_config(['--disable-values', '--enable-values']),
         ):
             self.assertIn(name, config)
-            self.assertEquals(PositiveOptionValue(), config[name])
+            self.assertEqual(PositiveOptionValue(), config[name])
 
         config = self.get_config(['--enable-values=foo'])
         self.assertIn(name, config)
-        self.assertEquals(PositiveOptionValue(('foo',)), config[name])
+        self.assertEqual(PositiveOptionValue(('foo',)), config[name])
 
         config = self.get_config(['--enable-values=foo,bar'])
         self.assertIn(name, config)
         self.assertTrue(config[name])
-        self.assertEquals(PositiveOptionValue(('foo', 'bar')), config[name])
+        self.assertEqual(PositiveOptionValue(('foo', 'bar')), config[name])
 
     def test_values2(self):
         self.test_values('VALUES2')
@@ -187,12 +187,12 @@
     def test_returned_default(self):
         config = self.get_config(['--enable-simple'])
         self.assertIn('DEFAULTED', config)
-        self.assertEquals(
+        self.assertEqual(
             PositiveOptionValue(('simple',)), config['DEFAULTED'])
 
         config = self.get_config(['--disable-simple'])
         self.assertIn('DEFAULTED', config)
-        self.assertEquals(
+        self.assertEqual(
             PositiveOptionValue(('not-simple',)), config['DEFAULTED'])
 
     def test_returned_choices(self):
@@ -200,13 +200,13 @@
             config = self.get_config(
                 ['--enable-values=alpha', '--returned-choices=%s' % val])
             self.assertIn('CHOICES', config)
-            self.assertEquals(PositiveOptionValue((val,)), config['CHOICES'])
+            self.assertEqual(PositiveOptionValue((val,)), config['CHOICES'])
 
         for val in ('0', '1', '2'):
             config = self.get_config(
                 ['--enable-values=numeric', '--returned-choices=%s' % val])
             self.assertIn('CHOICES', config)
-            self.assertEquals(PositiveOptionValue((val,)), config['CHOICES'])
+            self.assertEqual(PositiveOptionValue((val,)), config['CHOICES'])
 
         with self.assertRaises(InvalidOptionError):
             self.get_config(['--enable-values=numeric',
@@ -218,12 +218,12 @@
     def test_included(self):
         config = self.get_config(env={'CC': 'gcc'})
         self.assertIn('IS_GCC', config)
-        self.assertEquals(config['IS_GCC'], True)
+        self.assertEqual(config['IS_GCC'], True)
 
         config = self.get_config(
             ['--enable-include=extra.configure', '--extra'])
         self.assertIn('EXTRA', config)
-        self.assertEquals(PositiveOptionValue(), config['EXTRA'])
+        self.assertEqual(PositiveOptionValue(), config['EXTRA'])
 
         with self.assertRaises(InvalidOptionError):
             self.get_config(['--extra'])
@@ -231,7 +231,7 @@
     def test_template(self):
         config = self.get_config(env={'CC': 'gcc'})
         self.assertIn('CFLAGS', config)
-        self.assertEquals(config['CFLAGS'], ['-Werror=foobar'])
+        self.assertEqual(config['CFLAGS'], ['-Werror=foobar'])
 
         config = self.get_config(env={'CC': 'clang'})
         self.assertNotIn('CFLAGS', config)
@@ -288,7 +288,7 @@
             sandbox
         )
 
-        import __builtin__
+        import builtins
         self.assertIs(sandbox['foo'](), __builtin__)
 
         exec_(textwrap.dedent('''
@@ -300,7 +300,7 @@
         )
 
         f = sandbox['foo']()
-        self.assertEquals(f.name, os.devnull)
+        self.assertEqual(f.name, os.devnull)
         f.close()
 
         # This unlocks the sandbox
@@ -336,8 +336,8 @@
         self.assertIs(sandbox['foo'](), sandbox)
 
         # Nothing leaked from the function being executed
-        self.assertEquals(sandbox.keys(), ['__builtins__', 'foo'])
-        self.assertEquals(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
+        self.assertEqual(list(sandbox.keys()), ['__builtins__', 'foo'])
+        self.assertEqual(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
 
         exec_(textwrap.dedent('''
             @template
@@ -354,7 +354,7 @@
         with self.assertRaises(NameError) as e:
             sandbox._depends[sandbox['bar']].result
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "global name 'sys' is not defined")
 
     def test_apply_imports(self):
@@ -380,28 +380,28 @@
             sandbox
         )
 
-        self.assertEquals(len(imports), 1)
+        self.assertEqual(len(imports), 1)
 
     def test_os_path(self):
         config = self.get_config(['--with-imports=%s' % __file__])
         self.assertIn('HAS_ABSPATH', config)
-        self.assertEquals(config['HAS_ABSPATH'], True)
+        self.assertEqual(config['HAS_ABSPATH'], True)
         self.assertIn('HAS_GETATIME', config)
-        self.assertEquals(config['HAS_GETATIME'], True)
+        self.assertEqual(config['HAS_GETATIME'], True)
         self.assertIn('HAS_GETATIME2', config)
-        self.assertEquals(config['HAS_GETATIME2'], False)
+        self.assertEqual(config['HAS_GETATIME2'], False)
 
     def test_template_call(self):
         config = self.get_config(env={'CC': 'gcc'})
         self.assertIn('TEMPLATE_VALUE', config)
-        self.assertEquals(config['TEMPLATE_VALUE'], 42)
+        self.assertEqual(config['TEMPLATE_VALUE'], 42)
         self.assertIn('TEMPLATE_VALUE_2', config)
-        self.assertEquals(config['TEMPLATE_VALUE_2'], 21)
+        self.assertEqual(config['TEMPLATE_VALUE_2'], 21)
 
     def test_template_imports(self):
         config = self.get_config(['--enable-imports-in-template'])
         self.assertIn('PLATFORM', config)
-        self.assertEquals(config['PLATFORM'], sys.platform)
+        self.assertEqual(config['PLATFORM'], sys.platform)
 
     def test_decorators(self):
         config = {}
@@ -419,27 +419,27 @@
             return self.get_config(*args, configure='set_config.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config(['--set-foo'])
         self.assertIn('FOO', config)
-        self.assertEquals(config['FOO'], True)
+        self.assertEqual(config['FOO'], True)
 
         config = get_config(['--set-bar'])
         self.assertNotIn('FOO', config)
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], True)
+        self.assertEqual(config['BAR'], True)
 
         config = get_config(['--set-value=qux'])
         self.assertIn('VALUE', config)
-        self.assertEquals(config['VALUE'], 'qux')
+        self.assertEqual(config['VALUE'], 'qux')
 
         config = get_config(['--set-name=hoge'])
         self.assertIn('hoge', config)
-        self.assertEquals(config['hoge'], True)
+        self.assertEqual(config['hoge'], True)
 
         config = get_config([])
-        self.assertEquals(config, {'BAR': False})
+        self.assertEqual(config, {'BAR': False})
 
         with self.assertRaises(ConfigureError):
             # Both --set-foo and --set-name=FOO are going to try to
@@ -454,11 +454,11 @@
             set_config('QUX', 'qux', when='--with-qux')
         '''):
             config = self.get_config()
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': 'foo',
             })
             config = self.get_config(['--with-qux'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': 'foo',
                 'QUX': 'qux',
             })
@@ -468,27 +468,27 @@
             return self.get_config(*args, configure='set_define.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {'DEFINES': {}})
+        self.assertEqual(config, {'DEFINES': {}})
 
         config = get_config(['--set-foo'])
         self.assertIn('FOO', config['DEFINES'])
-        self.assertEquals(config['DEFINES']['FOO'], True)
+        self.assertEqual(config['DEFINES']['FOO'], True)
 
         config = get_config(['--set-bar'])
         self.assertNotIn('FOO', config['DEFINES'])
         self.assertIn('BAR', config['DEFINES'])
-        self.assertEquals(config['DEFINES']['BAR'], True)
+        self.assertEqual(config['DEFINES']['BAR'], True)
 
         config = get_config(['--set-value=qux'])
         self.assertIn('VALUE', config['DEFINES'])
-        self.assertEquals(config['DEFINES']['VALUE'], 'qux')
+        self.assertEqual(config['DEFINES']['VALUE'], 'qux')
 
         config = get_config(['--set-name=hoge'])
         self.assertIn('hoge', config['DEFINES'])
-        self.assertEquals(config['DEFINES']['hoge'], True)
+        self.assertEqual(config['DEFINES']['hoge'], True)
 
         config = get_config([])
-        self.assertEquals(config['DEFINES'], {'BAR': False})
+        self.assertEqual(config['DEFINES'], {'BAR': False})
 
         with self.assertRaises(ConfigureError):
             # Both --set-foo and --set-name=FOO are going to try to
@@ -503,11 +503,11 @@
             set_define('QUX', 'qux', when='--with-qux')
         '''):
             config = self.get_config()
-            self.assertEquals(config['DEFINES'], {
+            self.assertEqual(config['DEFINES'], {
                 'FOO': 'foo',
             })
             config = self.get_config(['--with-qux'])
-            self.assertEquals(config['DEFINES'], {
+            self.assertEqual(config['DEFINES'], {
                 'FOO': 'foo',
                 'QUX': 'qux',
             })
@@ -518,19 +518,19 @@
                 *args, configure='imply_option/simple.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config([])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config(['--enable-foo'])
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], PositiveOptionValue())
+        self.assertEqual(config['BAR'], PositiveOptionValue())
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--enable-foo', '--disable-bar'])
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "'--enable-bar' implied by '--enable-foo' conflicts with "
             "'--disable-bar' from the command-line")
@@ -541,31 +541,31 @@
                 *args, configure='imply_option/negative.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config([])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config(['--enable-foo'])
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], NegativeOptionValue())
+        self.assertEqual(config['BAR'], NegativeOptionValue())
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--enable-foo', '--enable-bar'])
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "'--disable-bar' implied by '--enable-foo' conflicts with "
             "'--enable-bar' from the command-line")
 
         config = get_config(['--disable-hoge'])
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], NegativeOptionValue())
+        self.assertEqual(config['BAR'], NegativeOptionValue())
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--disable-hoge', '--enable-bar'])
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "'--disable-bar' implied by '--disable-hoge' conflicts with "
             "'--enable-bar' from the command-line")
@@ -576,23 +576,23 @@
                 *args, configure='imply_option/values.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config([])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config(['--enable-foo=a'])
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], PositiveOptionValue(('a',)))
+        self.assertEqual(config['BAR'], PositiveOptionValue(('a',)))
 
         config = get_config(['--enable-foo=a,b'])
         self.assertIn('BAR', config)
-        self.assertEquals(config['BAR'], PositiveOptionValue(('a','b')))
+        self.assertEqual(config['BAR'], PositiveOptionValue(('a','b')))
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--enable-foo=a,b', '--disable-bar'])
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "'--enable-bar=a,b' implied by '--enable-foo' conflicts with "
             "'--disable-bar' from the command-line")
@@ -603,15 +603,15 @@
                 *args, configure='imply_option/infer.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config([])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--enable-foo', '--disable-bar'])
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "'--enable-bar' implied by '--enable-foo' conflicts with "
             "'--disable-bar' from the command-line")
@@ -619,7 +619,7 @@
         with self.assertRaises(ConfigureError) as e:
             self.get_config([], configure='imply_option/infer_ko.configure')
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             "Cannot infer what implies '--enable-bar'. Please add a `reason` "
             "to the `imply_option` call.")
@@ -630,25 +630,25 @@
                 *args, configure='imply_option/imm.configure')
 
         help, config = get_config(['--help'])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config = get_config([])
-        self.assertEquals(config, {})
+        self.assertEqual(config, {})
 
         config_path = mozpath.abspath(
             mozpath.join(test_data_path, 'imply_option', 'imm.configure'))
 
-        with self.assertRaisesRegexp(InvalidOptionError,
+        with self.assertRaisesRegex(InvalidOptionError,
             "--enable-foo' implied by 'imply_option at %s:7' conflicts with "
             "'--disable-foo' from the command-line" % config_path):
             get_config(['--disable-foo'])
 
-        with self.assertRaisesRegexp(InvalidOptionError,
+        with self.assertRaisesRegex(InvalidOptionError,
             "--enable-bar=foo,bar' implied by 'imply_option at %s:16' conflicts"
             " with '--enable-bar=a,b,c' from the command-line" % config_path):
             get_config(['--enable-bar=a,b,c'])
 
-        with self.assertRaisesRegexp(InvalidOptionError,
+        with self.assertRaisesRegex(InvalidOptionError,
             "--enable-baz=BAZ' implied by 'imply_option at %s:25' conflicts"
             " with '--enable-baz=QUUX' from the command-line" % config_path):
             get_config(['--enable-baz=QUUX'])
@@ -660,7 +660,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "`--with-foo`, emitted from `%s` line 2, is unknown."
                           % mozpath.join(test_data_path, 'moz.configure'))
 
@@ -675,7 +675,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Unexpected type: 'int'")
 
     def test_imply_option_when(self):
@@ -686,12 +686,12 @@
             set_config('QUX', depends('--with-qux')(lambda x: x))
         '''):
             config = self.get_config()
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'QUX': NegativeOptionValue(),
             })
 
             config = self.get_config(['--with-foo'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'QUX': PositiveOptionValue(),
             })
 
@@ -700,7 +700,7 @@
             with self.moz_configure('option("--with-foo", help="foo")'):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `--with-foo` is not handled ; reference it with a @depends'
         )
@@ -712,7 +712,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `--with-foo` already defined'
         )
@@ -724,7 +724,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `MOZ_FOO` already defined'
         )
@@ -736,7 +736,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `MOZ_FOO` already defined'
         )
@@ -748,7 +748,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `MOZ_FOO` already defined'
         )
@@ -760,7 +760,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Option `--with-foo` already defined'
         )
@@ -776,18 +776,18 @@
             set_config('QUX', depends('--with-qux', when='--with-foo')(lambda x: x))
         '''):
             config = self.get_config()
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': NegativeOptionValue(),
             })
 
             config = self.get_config(['--with-foo'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': PositiveOptionValue(),
                 'QUX': NegativeOptionValue(),
             })
 
             config = self.get_config(['--with-foo', '--with-qux'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': PositiveOptionValue(),
                 'QUX': PositiveOptionValue(),
             })
@@ -795,7 +795,7 @@
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config(['--with-bar'])
 
-            self.assertEquals(
+            self.assertEqual(
                 e.exception.message,
                 '--with-bar is not available in this configuration'
             )
@@ -803,7 +803,7 @@
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config(['--with-qux'])
 
-            self.assertEquals(
+            self.assertEqual(
                 e.exception.message,
                 '--with-qux is not available in this configuration'
             )
@@ -811,18 +811,18 @@
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config(['QUX=1'])
 
-            self.assertEquals(
+            self.assertEqual(
                 e.exception.message,
                 'QUX is not available in this configuration'
             )
 
             config = self.get_config(env={'QUX': '1'})
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': NegativeOptionValue(),
             })
 
             help, config = self.get_config(['--help'])
-            self.assertEquals(help, textwrap.dedent('''\
+            self.assertEqual(help, textwrap.dedent('''\
                 Usage: configure [options]
 
                 Options: [defaults in brackets after descriptions]
@@ -833,7 +833,7 @@
             '''))
 
             help, config = self.get_config(['--help', '--with-foo'])
-            self.assertEquals(help, textwrap.dedent('''\
+            self.assertEqual(help, textwrap.dedent('''\
                 Usage: configure [options]
 
                 Options: [defaults in brackets after descriptions]
@@ -851,7 +851,7 @@
             with self.assertRaises(ConfigureError) as e:
                 self.get_config()
 
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               '@depends function needs the same `when` as '
                               'options it depends on')
 
@@ -868,7 +868,7 @@
             with self.assertRaises(ConfigureError) as e:
                 self.get_config()
 
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               '@depends function needs the same `when` as '
                               'options it depends on')
 
@@ -877,7 +877,7 @@
             with self.moz_configure('include("../foo.configure")'):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Cannot include `%s` because it is not in a subdirectory of `%s`'
             % (mozpath.normpath(mozpath.join(test_data_path, '..',
@@ -892,7 +892,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'Cannot include `%s` because it was included already.'
             % mozpath.normpath(mozpath.join(test_data_path,
@@ -905,7 +905,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message, "Unexpected type: 'int'")
+        self.assertEqual(e.exception.message, "Unexpected type: 'int'")
 
     def test_include_when(self):
         with MockedOpen({
@@ -948,26 +948,26 @@
             '''),
         }):
             config = self.get_config()
-            self.assertEquals(config, {})
+            self.assertEqual(config, {})
 
             config = self.get_config(['--with-foo'])
-            self.assertEquals(config, {})
+            self.assertEqual(config, {})
 
             config = self.get_config(['--with-bar'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'BAR': 'bar',
             })
 
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config(['--with-qux'])
 
-            self.assertEquals(
+            self.assertEqual(
                 e.exception.message,
                 '--with-qux is not available in this configuration'
             )
 
             config = self.get_config(['--with-foo', '--with-foo-really'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': 'foo',
                 'FOO2': True,
             })
@@ -979,7 +979,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message, 'Cannot reassign builtins')
+        self.assertEqual(e.exception.message, 'Cannot reassign builtins')
 
         with self.assertRaises(KeyError) as e:
             with self.moz_configure('''
@@ -987,7 +987,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           'Cannot assign `foo` because it is neither a '
                           '@depends nor a @template')
 
@@ -1000,7 +1000,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "@depends needs at least one argument")
 
         with self.assertRaises(ConfigureError) as e:
@@ -1011,7 +1011,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "'--with-foo' is not a known option. Maybe it's "
                           "declared too late?")
 
@@ -1023,7 +1023,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Option must not contain an '='")
 
         with self.assertRaises(TypeError) as e:
@@ -1034,7 +1034,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Cannot use object of type 'int' as argument "
                           "to @depends")
 
@@ -1046,7 +1046,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Cannot decorate generator functions with @depends")
 
         with self.assertRaises(TypeError) as e:
@@ -1055,7 +1055,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Unexpected type: 'int'")
 
         with self.assertRaises(ConfigureError) as e:
@@ -1069,7 +1069,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The `foo` function may not be called")
 
         with self.assertRaises(TypeError) as e:
@@ -1080,7 +1080,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "depends_impl() got an unexpected keyword argument 'foo'")
 
     def test_depends_when(self):
@@ -1105,12 +1105,12 @@
             set_config('QUX', qux)
         '''):
             config = self.get_config()
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': 'foo',
             })
 
             config = self.get_config(['--with-qux'])
-            self.assertEquals(config, {
+            self.assertEqual(config, {
                 'FOO': 'foo',
                 'QUX': 'qux',
             })
@@ -1125,7 +1125,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           '@imports must appear after @template')
 
         with self.assertRaises(ConfigureError) as e:
@@ -1138,7 +1138,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           '@imports must appear after @depends')
 
         for import_ in (
@@ -1155,7 +1155,7 @@
                 ''' % import_):
                     self.get_config()
 
-            self.assertEquals(e.exception.message, "Unexpected type: 'int'")
+            self.assertEqual(e.exception.message, "Unexpected type: 'int'")
 
         with self.assertRaises(TypeError) as e:
             with self.moz_configure('''
@@ -1166,7 +1166,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message, "Unexpected type: 'int'")
+        self.assertEqual(e.exception.message, "Unexpected type: 'int'")
 
         with self.assertRaises(ValueError) as e:
             with self.moz_configure('''
@@ -1176,7 +1176,7 @@
             '''):
                 self.get_config()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Invalid argument to @imports: 'os*'")
 
     def test_only_when(self):
@@ -1231,7 +1231,7 @@
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config(['--foo'])
 
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               '--foo is not available in this configuration')
 
         # Cannot depend on an option defined in a only_when block, because we
@@ -1242,7 +1242,7 @@
             with self.assertRaises(ConfigureError) as e:
                 self.get_config()
 
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               '@depends function needs the same `when` as '
                               'options it depends on')
 
@@ -1259,7 +1259,7 @@
             with self.assertRaises(InvalidOptionError) as e:
                 self.get_config()
 
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               '--foo is not available in this configuration')
 
         # And similarly doesn't fail when the condition is true.
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_lint.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_lint.py	(refactored)
@@ -2,9 +2,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
 
-from StringIO import StringIO
+
+from io import StringIO
 import os
 import textwrap
 import unittest
@@ -62,7 +62,7 @@
             '''):
                 self.lint_test()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "`bar` depends on '--help' and `foo`. "
                           "`foo` must depend on '--help'")
 
@@ -85,7 +85,7 @@
             '''):
                 self.lint_test()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "`bar` depends on '--help' and `foo`. "
                           "`foo` must depend on '--help'")
 
@@ -111,7 +111,7 @@
             '''):
                 self.lint_test()
 
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "Missing @depends for `foo`: '--help'")
 
         # There is a default restricted `os` module when there is no explicit
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_moz_configure.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_moz_configure.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 from mozunit import main
 from mozpack import path as mozpath
@@ -23,10 +23,10 @@
             shell = mozpath.abspath('/bin/sh')
             return result.replace('CONFIG_SHELL=%s ' % shell, '')
 
-        self.assertEquals('--enable-application=browser',
+        self.assertEqual('--enable-application=browser',
                           get_value_for(['--enable-application=browser']))
 
-        self.assertEquals('--enable-application=browser '
+        self.assertEqual('--enable-application=browser '
                           'MOZ_PROFILING=1',
                           get_value_for(['--enable-application=browser',
                                          'MOZ_PROFILING=1']))
@@ -35,25 +35,25 @@
             environ={'MOZ_PROFILING': '1'},
             mozconfig='ac_add_options --enable-project=js')
 
-        self.assertEquals('--enable-project=js MOZ_PROFILING=1',
+        self.assertEqual('--enable-project=js MOZ_PROFILING=1',
                           value)
 
         # --disable-js-shell is the default, so it's filtered out.
-        self.assertEquals('--enable-application=browser',
+        self.assertEqual('--enable-application=browser',
                           get_value_for(['--enable-application=browser',
                                          '--disable-js-shell']))
 
         # Normally, --without-foo would be filtered out because that's the
         # default, but since it is a (fake) old-configure option, it always
         # appears.
-        self.assertEquals('--enable-application=browser --without-foo',
+        self.assertEqual('--enable-application=browser --without-foo',
                           get_value_for(['--enable-application=browser',
                                          '--without-foo']))
-        self.assertEquals('--enable-application=browser --with-foo',
+        self.assertEqual('--enable-application=browser --with-foo',
                           get_value_for(['--enable-application=browser',
                                          '--with-foo']))
 
-        self.assertEquals("--enable-application=browser '--with-foo=foo bar'",
+        self.assertEqual("--enable-application=browser '--with-foo=foo bar'",
                           get_value_for(['--enable-application=browser',
                                          '--with-foo=foo bar']))
 
@@ -65,7 +65,7 @@
                 self.version = version
 
             def __call__(self, stdin, args):
-                this.assertEquals(args, ('-version',))
+                this.assertEqual(args, ('-version',))
                 return 0, self.version, ''
 
         def check_nsis_version(version):
@@ -80,13 +80,13 @@
         with self.assertRaises(SystemExit) as e:
             check_nsis_version('v3.0a2')
 
-        self.assertEquals(check_nsis_version('v3.0b1'), '3.0b1')
-        self.assertEquals(check_nsis_version('v3.0b2'), '3.0b2')
-        self.assertEquals(check_nsis_version('v3.0rc1'), '3.0rc1')
-        self.assertEquals(check_nsis_version('v3.0'), '3.0')
-        self.assertEquals(check_nsis_version('v3.0-2'), '3.0')
-        self.assertEquals(check_nsis_version('v3.0.1'), '3.0')
-        self.assertEquals(check_nsis_version('v3.1'), '3.1')
+        self.assertEqual(check_nsis_version('v3.0b1'), '3.0b1')
+        self.assertEqual(check_nsis_version('v3.0b2'), '3.0b2')
+        self.assertEqual(check_nsis_version('v3.0rc1'), '3.0rc1')
+        self.assertEqual(check_nsis_version('v3.0'), '3.0')
+        self.assertEqual(check_nsis_version('v3.0-2'), '3.0')
+        self.assertEqual(check_nsis_version('v3.0.1'), '3.0')
+        self.assertEqual(check_nsis_version('v3.1'), '3.1')
 
 
 if __name__ == '__main__':
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_options.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_options.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import unittest
 
@@ -27,139 +27,139 @@
 class TestOption(unittest.TestCase):
     def test_option(self):
         option = Option('--option')
-        self.assertEquals(option.prefix, '')
-        self.assertEquals(option.name, 'option')
-        self.assertEquals(option.env, None)
+        self.assertEqual(option.prefix, '')
+        self.assertEqual(option.name, 'option')
+        self.assertEqual(option.env, None)
         self.assertFalse(option.default)
 
         option = Option('--enable-option')
-        self.assertEquals(option.prefix, 'enable')
-        self.assertEquals(option.name, 'option')
-        self.assertEquals(option.env, None)
+        self.assertEqual(option.prefix, 'enable')
+        self.assertEqual(option.name, 'option')
+        self.assertEqual(option.env, None)
         self.assertFalse(option.default)
 
         option = Option('--disable-option')
-        self.assertEquals(option.prefix, 'disable')
-        self.assertEquals(option.name, 'option')
-        self.assertEquals(option.env, None)
+        self.assertEqual(option.prefix, 'disable')
+        self.assertEqual(option.name, 'option')
+        self.assertEqual(option.env, None)
         self.assertTrue(option.default)
 
         option = Option('--with-option')
-        self.assertEquals(option.prefix, 'with')
-        self.assertEquals(option.name, 'option')
-        self.assertEquals(option.env, None)
+        self.assertEqual(option.prefix, 'with')
+        self.assertEqual(option.name, 'option')
+        self.assertEqual(option.env, None)
         self.assertFalse(option.default)
 
         option = Option('--without-option')
-        self.assertEquals(option.prefix, 'without')
-        self.assertEquals(option.name, 'option')
-        self.assertEquals(option.env, None)
+        self.assertEqual(option.prefix, 'without')
+        self.assertEqual(option.name, 'option')
+        self.assertEqual(option.env, None)
         self.assertTrue(option.default)
 
         option = Option('--without-option-foo', env='MOZ_OPTION')
-        self.assertEquals(option.env, 'MOZ_OPTION')
+        self.assertEqual(option.env, 'MOZ_OPTION')
 
         option = Option(env='MOZ_OPTION')
-        self.assertEquals(option.prefix, '')
-        self.assertEquals(option.name, None)
-        self.assertEquals(option.env, 'MOZ_OPTION')
+        self.assertEqual(option.prefix, '')
+        self.assertEqual(option.name, None)
+        self.assertEqual(option.env, 'MOZ_OPTION')
         self.assertFalse(option.default)
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=0, default=('a',))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=1, default=())
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'default must be a bool, a string or a tuple of strings')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=1, default=True)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=1, default=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=2, default=())
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'default must be a bool, a string or a tuple of strings')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=2, default=True)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=2, default=('a',))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs='?', default=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs='+', default=())
-        self.assertEquals(
+        self.assertEqual(
             e.exception.message,
             'default must be a bool, a string or a tuple of strings')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs='+', default=True)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         # --disable options with a nargs value that requires at least one
         # argument need to be given a default.
         with self.assertRaises(InvalidOptionError) as e:
             Option('--disable-option', nargs=1)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--disable-option', nargs='+')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
         # Test nargs inference from default value
         option = Option('--with-foo', default=True)
-        self.assertEquals(option.nargs, 0)
+        self.assertEqual(option.nargs, 0)
 
         option = Option('--with-foo', default=False)
-        self.assertEquals(option.nargs, 0)
+        self.assertEqual(option.nargs, 0)
 
         option = Option('--with-foo', default='a')
-        self.assertEquals(option.nargs, '?')
+        self.assertEqual(option.nargs, '?')
 
         option = Option('--with-foo', default=('a',))
-        self.assertEquals(option.nargs, '?')
+        self.assertEqual(option.nargs, '?')
 
         option = Option('--with-foo', default=('a', 'b'))
-        self.assertEquals(option.nargs, '*')
+        self.assertEqual(option.nargs, '*')
 
         option = Option(env='FOO', default=True)
-        self.assertEquals(option.nargs, 0)
+        self.assertEqual(option.nargs, 0)
 
         option = Option(env='FOO', default=False)
-        self.assertEquals(option.nargs, 0)
+        self.assertEqual(option.nargs, 0)
 
         option = Option(env='FOO', default='a')
-        self.assertEquals(option.nargs, '?')
+        self.assertEqual(option.nargs, '?')
 
         option = Option(env='FOO', default=('a',))
-        self.assertEquals(option.nargs, '?')
+        self.assertEqual(option.nargs, '?')
 
         option = Option(env='FOO', default=('a', 'b'))
-        self.assertEquals(option.nargs, '*')
+        self.assertEqual(option.nargs, '*')
 
     def test_option_option(self):
         for option in (
@@ -169,70 +169,70 @@
             '--with-option',
             '--without-option',
         ):
-            self.assertEquals(Option(option).option, option)
-            self.assertEquals(Option(option, env='FOO').option, option)
+            self.assertEqual(Option(option).option, option)
+            self.assertEqual(Option(option, env='FOO').option, option)
 
             opt = Option(option, default=False)
-            self.assertEquals(opt.option,
+            self.assertEqual(opt.option,
                               option.replace('-disable-', '-enable-')
                                     .replace('-without-', '-with-'))
 
             opt = Option(option, default=True)
-            self.assertEquals(opt.option,
+            self.assertEqual(opt.option,
                               option.replace('-enable-', '-disable-')
                                     .replace('-with-', '-without-'))
 
-        self.assertEquals(Option(env='FOO').option, 'FOO')
+        self.assertEqual(Option(env='FOO').option, 'FOO')
 
     def test_option_choices(self):
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=3, choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           'Not enough `choices` for `nargs`')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--without-option', nargs=1, choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           'A `default` must be given along with `choices`')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--without-option', nargs='+', choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           'A `default` must be given along with `choices`')
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--without-option', default='c', choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The `default` value must be one of 'a', 'b'")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--without-option', default=('a', 'c',), choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The `default` value must be one of 'a', 'b'")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--without-option', default=('c',), choices=('a', 'b'))
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The `default` value must be one of 'a', 'b'")
 
         option = Option('--with-option', nargs='+', choices=('a', 'b'))
         with self.assertRaises(InvalidOptionError) as e:
             option.get_value('--with-option=c')
-        self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
+        self.assertEqual(e.exception.message, "'c' is not one of 'a', 'b'")
 
         value = option.get_value('--with-option=b,a')
         self.assertTrue(value)
-        self.assertEquals(PositiveOptionValue(('b', 'a')), value)
+        self.assertEqual(PositiveOptionValue(('b', 'a')), value)
 
         option = Option('--without-option', nargs='*', default='a',
                         choices=('a', 'b'))
         with self.assertRaises(InvalidOptionError) as e:
             option.get_value('--with-option=c')
-        self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
+        self.assertEqual(e.exception.message, "'c' is not one of 'a', 'b'")
 
         value = option.get_value('--with-option=b,a')
         self.assertTrue(value)
-        self.assertEquals(PositiveOptionValue(('b', 'a')), value)
+        self.assertEqual(PositiveOptionValue(('b', 'a')), value)
 
         # Test nargs inference from choices
         option = Option('--with-option', choices=('a', 'b'))
@@ -243,71 +243,71 @@
                         choices=('a', 'b', 'c', 'd'))
 
         value = option.get_value('--with-option=+d')
-        self.assertEquals(PositiveOptionValue(('b', 'c', 'd')), value)
+        self.assertEqual(PositiveOptionValue(('b', 'c', 'd')), value)
 
         value = option.get_value('--with-option=-b')
-        self.assertEquals(PositiveOptionValue(('c',)), value)
+        self.assertEqual(PositiveOptionValue(('c',)), value)
 
         value = option.get_value('--with-option=-b,+d')
-        self.assertEquals(PositiveOptionValue(('c','d')), value)
+        self.assertEqual(PositiveOptionValue(('c','d')), value)
 
         # Adding something that is in the default is fine
         value = option.get_value('--with-option=+b')
-        self.assertEquals(PositiveOptionValue(('b', 'c')), value)
+        self.assertEqual(PositiveOptionValue(('b', 'c')), value)
 
         # Removing something that is not in the default is fine, as long as it
         # is one of the choices
         value = option.get_value('--with-option=-a')
-        self.assertEquals(PositiveOptionValue(('b', 'c')), value)
+        self.assertEqual(PositiveOptionValue(('b', 'c')), value)
 
         with self.assertRaises(InvalidOptionError) as e:
             option.get_value('--with-option=-e')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "'e' is not one of 'a', 'b', 'c', 'd'")
 
         # Other "not a choice" errors.
         with self.assertRaises(InvalidOptionError) as e:
             option.get_value('--with-option=+e')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "'e' is not one of 'a', 'b', 'c', 'd'")
 
         with self.assertRaises(InvalidOptionError) as e:
             option.get_value('--with-option=e')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "'e' is not one of 'a', 'b', 'c', 'd'")
 
     def test_option_value_format(self):
         val = PositiveOptionValue()
-        self.assertEquals('--with-value', val.format('--with-value'))
-        self.assertEquals('--with-value', val.format('--without-value'))
-        self.assertEquals('--enable-value', val.format('--enable-value'))
-        self.assertEquals('--enable-value', val.format('--disable-value'))
-        self.assertEquals('--value', val.format('--value'))
-        self.assertEquals('VALUE=1', val.format('VALUE'))
+        self.assertEqual('--with-value', val.format('--with-value'))
+        self.assertEqual('--with-value', val.format('--without-value'))
+        self.assertEqual('--enable-value', val.format('--enable-value'))
+        self.assertEqual('--enable-value', val.format('--disable-value'))
+        self.assertEqual('--value', val.format('--value'))
+        self.assertEqual('VALUE=1', val.format('VALUE'))
 
         val = PositiveOptionValue(('a',))
-        self.assertEquals('--with-value=a', val.format('--with-value'))
-        self.assertEquals('--with-value=a', val.format('--without-value'))
-        self.assertEquals('--enable-value=a', val.format('--enable-value'))
-        self.assertEquals('--enable-value=a', val.format('--disable-value'))
-        self.assertEquals('--value=a', val.format('--value'))
-        self.assertEquals('VALUE=a', val.format('VALUE'))
+        self.assertEqual('--with-value=a', val.format('--with-value'))
+        self.assertEqual('--with-value=a', val.format('--without-value'))
+        self.assertEqual('--enable-value=a', val.format('--enable-value'))
+        self.assertEqual('--enable-value=a', val.format('--disable-value'))
+        self.assertEqual('--value=a', val.format('--value'))
+        self.assertEqual('VALUE=a', val.format('VALUE'))
 
         val = PositiveOptionValue(('a', 'b'))
-        self.assertEquals('--with-value=a,b', val.format('--with-value'))
-        self.assertEquals('--with-value=a,b', val.format('--without-value'))
-        self.assertEquals('--enable-value=a,b', val.format('--enable-value'))
-        self.assertEquals('--enable-value=a,b', val.format('--disable-value'))
-        self.assertEquals('--value=a,b', val.format('--value'))
-        self.assertEquals('VALUE=a,b', val.format('VALUE'))
+        self.assertEqual('--with-value=a,b', val.format('--with-value'))
+        self.assertEqual('--with-value=a,b', val.format('--without-value'))
+        self.assertEqual('--enable-value=a,b', val.format('--enable-value'))
+        self.assertEqual('--enable-value=a,b', val.format('--disable-value'))
+        self.assertEqual('--value=a,b', val.format('--value'))
+        self.assertEqual('VALUE=a,b', val.format('VALUE'))
 
         val = NegativeOptionValue()
-        self.assertEquals('--without-value', val.format('--with-value'))
-        self.assertEquals('--without-value', val.format('--without-value'))
-        self.assertEquals('--disable-value', val.format('--enable-value'))
-        self.assertEquals('--disable-value', val.format('--disable-value'))
-        self.assertEquals('', val.format('--value'))
-        self.assertEquals('VALUE=', val.format('VALUE'))
+        self.assertEqual('--without-value', val.format('--with-value'))
+        self.assertEqual('--without-value', val.format('--without-value'))
+        self.assertEqual('--disable-value', val.format('--enable-value'))
+        self.assertEqual('--disable-value', val.format('--disable-value'))
+        self.assertEqual('', val.format('--value'))
+        self.assertEqual('VALUE=', val.format('VALUE'))
 
     def test_option_value(self, name='option', nargs=0, default=None):
         disabled = name.startswith(('disable-', 'without-'))
@@ -324,28 +324,28 @@
 
         if nargs in (0, '?', '*') or disabled:
             value = option.get_value('--%s' % name, 'option')
-            self.assertEquals(value, posOptionValue())
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, posOptionValue())
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s' % name)
             if nargs == 1:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes 1 value' % name)
             elif nargs == '+':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes 1 or more values' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes 2 values' % name)
 
         value = option.get_value('')
-        self.assertEquals(value, defaultValue)
-        self.assertEquals(value.origin, 'default')
+        self.assertEqual(value, defaultValue)
+        self.assertEqual(value.origin, 'default')
 
         value = option.get_value(None)
-        self.assertEquals(value, defaultValue)
-        self.assertEquals(value.origin, 'default')
+        self.assertEqual(value, defaultValue)
+        self.assertEqual(value.origin, 'default')
 
         with self.assertRaises(AssertionError):
             value = option.get_value('MOZ_OPTION=', 'environment')
@@ -358,47 +358,47 @@
 
         if nargs in (1, '?', '*', '+') and not disabled:
             value = option.get_value('--%s=' % name, 'option')
-            self.assertEquals(value, PositiveOptionValue(('',)))
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, PositiveOptionValue(('',)))
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s=' % name)
             if disabled:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'Cannot pass a value to --%s' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes %d values' % (name, nargs))
 
         if nargs in (1, '?', '*', '+') and not disabled:
             value = option.get_value('--%s=foo' % name, 'option')
-            self.assertEquals(value, PositiveOptionValue(('foo',)))
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, PositiveOptionValue(('foo',)))
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s=foo' % name)
             if disabled:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'Cannot pass a value to --%s' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes %d values' % (name, nargs))
 
         if nargs in (2, '*', '+') and not disabled:
             value = option.get_value('--%s=foo,bar' % name, 'option')
-            self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s=foo,bar' % name, 'option')
             if disabled:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'Cannot pass a value to --%s' % name)
             elif nargs == '?':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes 0 or 1 values' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes %d value%s'
                                   % (name, nargs, 's' if nargs != 1 else ''))
 
@@ -406,59 +406,59 @@
                         default=default)
         if nargs in (0, '?', '*') or disabled:
             value = option.get_value('--%s' % name, 'option')
-            self.assertEquals(value, posOptionValue())
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, posOptionValue())
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s' % name)
             if disabled:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'Cannot pass a value to --%s' % name)
             elif nargs == '+':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes 1 or more values' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes %d value%s'
                                   % (name, nargs, 's' if nargs != 1 else ''))
 
         value = option.get_value('')
-        self.assertEquals(value, defaultValue)
-        self.assertEquals(value.origin, 'default')
+        self.assertEqual(value, defaultValue)
+        self.assertEqual(value.origin, 'default')
 
         value = option.get_value(None)
-        self.assertEquals(value, defaultValue)
-        self.assertEquals(value.origin, 'default')
+        self.assertEqual(value, defaultValue)
+        self.assertEqual(value.origin, 'default')
 
         value = option.get_value('MOZ_OPTION=', 'environment')
-        self.assertEquals(value, NegativeOptionValue())
-        self.assertEquals(value.origin, 'environment')
+        self.assertEqual(value, NegativeOptionValue())
+        self.assertEqual(value.origin, 'environment')
 
         if nargs in (0, '?', '*'):
             value = option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(value, PositiveOptionValue())
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue())
+            self.assertEqual(value.origin, 'environment')
         elif nargs in (1, '+'):
             value = option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('1',)))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('1',)))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
+            self.assertEqual(e.exception.message, 'MOZ_OPTION takes 2 values')
 
         if nargs in (1, '?', '*', '+') and not disabled:
             value = option.get_value('--%s=' % name, 'option')
-            self.assertEquals(value, PositiveOptionValue(('',)))
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, PositiveOptionValue(('',)))
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s=' % name, 'option')
             if disabled:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'Cannot pass a value to --%s' % name)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s takes %d values' % (name, nargs))
 
         with self.assertRaises(AssertionError):
@@ -466,26 +466,26 @@
 
         if nargs in (1, '?', '*', '+'):
             value = option.get_value('MOZ_OPTION=foo', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('foo',)))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('foo',)))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('MOZ_OPTION=foo', 'environment')
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               'MOZ_OPTION takes %d values' % nargs)
 
         if nargs in (2, '*', '+'):
             value = option.get_value('MOZ_OPTION=foo,bar', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('MOZ_OPTION=foo,bar', 'environment')
             if nargs == '?':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'MOZ_OPTION takes 0 or 1 values')
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'MOZ_OPTION takes %d value%s'
                                   % (nargs, 's' if nargs != 1 else ''))
 
@@ -497,26 +497,26 @@
             env_option.get_value('--%s' % name)
 
         value = env_option.get_value('')
-        self.assertEquals(value, defaultValue)
-        self.assertEquals(value.origin, 'default')
+        self.assertEqual(value, defaultValue)
+        self.assertEqual(value.origin, 'default')
 
         value = env_option.get_value('MOZ_OPTION=', 'environment')
-        self.assertEquals(value, negOptionValue())
-        self.assertEquals(value.origin, 'environment')
+        self.assertEqual(value, negOptionValue())
+        self.assertEqual(value.origin, 'environment')
 
         if nargs in (0, '?', '*'):
             value = env_option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(value, posOptionValue())
+            self.assertEqual(value, posOptionValue())
             self.assertTrue(value)
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value.origin, 'environment')
         elif nargs in (1, '+'):
             value = env_option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('1',)))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('1',)))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 env_option.get_value('MOZ_OPTION=1', 'environment')
-            self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
+            self.assertEqual(e.exception.message, 'MOZ_OPTION takes 2 values')
 
         with self.assertRaises(AssertionError) as e:
             env_option.get_value('--%s' % name)
@@ -526,26 +526,26 @@
 
         if nargs in (1, '?', '*', '+'):
             value = env_option.get_value('MOZ_OPTION=foo', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('foo',)))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('foo',)))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 env_option.get_value('MOZ_OPTION=foo', 'environment')
-            self.assertEquals(e.exception.message,
+            self.assertEqual(e.exception.message,
                               'MOZ_OPTION takes %d values' % nargs)
 
         if nargs in (2, '*', '+'):
             value = env_option.get_value('MOZ_OPTION=foo,bar', 'environment')
-            self.assertEquals(value, PositiveOptionValue(('foo', 'bar')))
-            self.assertEquals(value.origin, 'environment')
+            self.assertEqual(value, PositiveOptionValue(('foo', 'bar')))
+            self.assertEqual(value.origin, 'environment')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 env_option.get_value('MOZ_OPTION=foo,bar', 'environment')
             if nargs == '?':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'MOZ_OPTION takes 0 or 1 values')
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   'MOZ_OPTION takes %d value%s'
                                   % (nargs, 's' if nargs != 1 else ''))
 
@@ -557,28 +557,28 @@
                                         default=default)
 
         value = option.get_value('--%s-option' % disable, 'option')
-        self.assertEquals(value, NegativeOptionValue())
-        self.assertEquals(value.origin, 'option')
+        self.assertEqual(value, NegativeOptionValue())
+        self.assertEqual(value.origin, 'option')
 
         option = self.test_option_value('%s-option' % disable, nargs=nargs,
                                         default=default)
 
         if nargs in (0, '?', '*'):
             value = option.get_value('--%s-option' % enable, 'option')
-            self.assertEquals(value, PositiveOptionValue())
-            self.assertEquals(value.origin, 'option')
+            self.assertEqual(value, PositiveOptionValue())
+            self.assertEqual(value.origin, 'option')
         else:
             with self.assertRaises(InvalidOptionError) as e:
                 option.get_value('--%s-option' % enable, 'option')
             if nargs == 1:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s-option takes 1 value' % enable)
             elif nargs == '+':
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s-option takes 1 or more values'
                                   % enable)
             else:
-                self.assertEquals(e.exception.message,
+                self.assertEqual(e.exception.message,
                                   '--%s-option takes 2 values' % enable)
 
     def test_option_value_with(self):
@@ -587,12 +587,12 @@
     def test_option_value_invalid_nargs(self):
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs='foo')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "nargs must be a positive integer, '?', '*' or '+'")
 
         with self.assertRaises(InvalidOptionError) as e:
             Option('--option', nargs=-2)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "nargs must be a positive integer, '?', '*' or '+'")
 
     def test_option_value_nargs_1(self):
@@ -603,7 +603,7 @@
         # A default is required
         with self.assertRaises(InvalidOptionError) as e:
             Option('--disable-option', nargs=1)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
     def test_option_value_nargs_2(self):
@@ -614,7 +614,7 @@
         # A default is required
         with self.assertRaises(InvalidOptionError) as e:
             Option('--disable-option', nargs=2)
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
     def test_option_value_nargs_0_or_1(self):
@@ -641,7 +641,7 @@
         # A default is required
         with self.assertRaises(InvalidOptionError) as e:
             Option('--disable-option', nargs='+')
-        self.assertEquals(e.exception.message,
+        self.assertEqual(e.exception.message,
                           "The given `default` doesn't satisfy `nargs`")
 
 
@@ -649,109 +649,109 @@
     def test_basic(self):
         helper = CommandLineHelper({}, ['cmd', '--foo', '--bar'])
 
-        self.assertEquals(['--foo', '--bar'], list(helper))
+        self.assertEqual(['--foo', '--bar'], list(helper))
 
         helper.add('--enable-qux')
 
-        self.assertEquals(['--foo', '--bar', '--enable-qux'], list(helper))
+        self.assertEqual(['--foo', '--bar', '--enable-qux'], list(helper))
 
         value, option = helper.handle(Option('--bar'))
-        self.assertEquals(['--foo', '--enable-qux'], list(helper))
-        self.assertEquals(PositiveOptionValue(), value)
-        self.assertEquals('--bar', option)
+        self.assertEqual(['--foo', '--enable-qux'], list(helper))
+        self.assertEqual(PositiveOptionValue(), value)
+        self.assertEqual('--bar', option)
 
         value, option = helper.handle(Option('--baz'))
-        self.assertEquals(['--foo', '--enable-qux'], list(helper))
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals(None, option)
+        self.assertEqual(['--foo', '--enable-qux'], list(helper))
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual(None, option)
 
     def test_precedence(self):
         foo = Option('--with-foo', nargs='*')
         helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--with-foo=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--with-foo=a,b', option)
 
         helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b',
                                         '--without-foo'])
         value, option = helper.handle(foo)
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--without-foo', option)
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--without-foo', option)
 
         helper = CommandLineHelper({}, ['cmd', '--without-foo',
                                         '--with-foo=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--with-foo=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--with-foo=a,b', option)
 
         foo = Option('--with-foo', env='FOO', nargs='*')
         helper = CommandLineHelper({'FOO': ''}, ['cmd', '--with-foo=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--with-foo=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--with-foo=a,b', option)
 
         helper = CommandLineHelper({'FOO': 'a,b'}, ['cmd', '--without-foo'])
         value, option = helper.handle(foo)
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--without-foo', option)
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--without-foo', option)
 
         helper = CommandLineHelper({'FOO': ''}, ['cmd', '--with-bar=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals('environment', value.origin)
-        self.assertEquals('FOO=', option)
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual('environment', value.origin)
+        self.assertEqual('FOO=', option)
 
         helper = CommandLineHelper({'FOO': 'a,b'}, ['cmd', '--without-bar'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('environment', value.origin)
-        self.assertEquals('FOO=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('environment', value.origin)
+        self.assertEqual('FOO=a,b', option)
 
         helper = CommandLineHelper({}, ['cmd', '--with-foo=a,b', 'FOO='])
         value, option = helper.handle(foo)
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('FOO=', option)
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('FOO=', option)
 
         helper = CommandLineHelper({}, ['cmd', '--without-foo', 'FOO=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('FOO=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('FOO=a,b', option)
 
         helper = CommandLineHelper({}, ['cmd', 'FOO=', '--with-foo=a,b'])
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b')), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--with-foo=a,b', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b')), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--with-foo=a,b', option)
 
         helper = CommandLineHelper({}, ['cmd', 'FOO=a,b', '--without-foo'])
         value, option = helper.handle(foo)
-        self.assertEquals(NegativeOptionValue(), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--without-foo', option)
+        self.assertEqual(NegativeOptionValue(), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--without-foo', option)
 
     def test_extra_args(self):
         foo = Option('--with-foo', env='FOO', nargs='*')
         helper = CommandLineHelper({}, ['cmd'])
         helper.add('FOO=a,b,c', 'other-origin')
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
-        self.assertEquals('other-origin', value.origin)
-        self.assertEquals('FOO=a,b,c', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
+        self.assertEqual('other-origin', value.origin)
+        self.assertEqual('FOO=a,b,c', option)
 
         helper = CommandLineHelper({}, ['cmd'])
         helper.add('FOO=a,b,c', 'other-origin')
         helper.add('--with-foo=a,b,c', 'other-origin')
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
-        self.assertEquals('other-origin', value.origin)
-        self.assertEquals('--with-foo=a,b,c', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
+        self.assertEqual('other-origin', value.origin)
+        self.assertEqual('--with-foo=a,b,c', option)
 
         # Adding conflicting options is not allowed.
         helper = CommandLineHelper({}, ['cmd'])
@@ -771,9 +771,9 @@
         # But adding the same is allowed.
         helper.add('FOO=a,b,c', 'other-origin')
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
-        self.assertEquals('other-origin', value.origin)
-        self.assertEquals('FOO=a,b,c', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
+        self.assertEqual('other-origin', value.origin)
+        self.assertEqual('FOO=a,b,c', option)
 
         # The same rule as above applies when using the option form vs. the
         # variable form. But we can't detect it when .add is called.
@@ -799,9 +799,9 @@
         helper.add('FOO=a,b,c', 'other-origin')
         helper.add('--with-foo=a,b,c', 'other-origin')
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(('a', 'b', 'c')), value)
-        self.assertEquals('other-origin', value.origin)
-        self.assertEquals('--with-foo=a,b,c', option)
+        self.assertEqual(PositiveOptionValue(('a', 'b', 'c')), value)
+        self.assertEqual('other-origin', value.origin)
+        self.assertEqual('--with-foo=a,b,c', option)
 
         # Conflicts are also not allowed against what is in the
         # environment/on the command line.
@@ -831,19 +831,19 @@
         foo = Option('--foo',
                      possible_origins=('command-line',))
         value, option = helper.handle(foo)
-        self.assertEquals(PositiveOptionValue(), value)
-        self.assertEquals('command-line', value.origin)
-        self.assertEquals('--foo', option)
+        self.assertEqual(PositiveOptionValue(), value)
+        self.assertEqual('command-line', value.origin)
+        self.assertEqual('--foo', option)
 
         bar = Option('--bar',
                      possible_origins=('mozconfig',))
-        with self.assertRaisesRegexp(InvalidOptionError,
+        with self.assertRaisesRegex(InvalidOptionError,
             "--bar can not be set by command-line. Values are accepted from: mozconfig"):
             helper.handle(bar)
 
         baz = Option(env='BAZ',
                      possible_origins=('implied',))
-        with self.assertRaisesRegexp(InvalidOptionError,
+        with self.assertRaisesRegex(InvalidOptionError,
             "BAZ=1 can not be set by environment. Values are accepted from: implied"):
             helper.handle(baz)
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py	(refactored)
@@ -2,12 +2,12 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import logging
 import os
 
-from StringIO import StringIO
+from io import StringIO
 
 from mozunit import main
 
@@ -291,9 +291,9 @@
                 compiler = sandbox._value_for(sandbox[var])
                 # Add var on both ends to make it clear which of the
                 # variables is failing the test when that happens.
-                self.assertEquals((var, compiler), (var, result))
+                self.assertEqual((var, compiler), (var, result))
             except SystemExit:
-                self.assertEquals((var, result),
+                self.assertEqual((var, result),
                                   (var, self.out.getvalue().strip()))
                 return
 
@@ -471,7 +471,7 @@
         # We'll try gcc and clang, but since there is no gcc (gcc-x.y doesn't
         # count), find clang.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) not in ('gcc', 'g++')
         }
         self.do_toolchain_test(paths, {
@@ -506,7 +506,7 @@
         # Even if there are gcc-x.y or clang-x.y compilers available, we
         # don't try them. This could be considered something to improve.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) not in ('gcc', 'g++', 'clang', 'clang++')
         }
         self.do_toolchain_test(paths, {
@@ -687,7 +687,7 @@
     def test_not_gcc(self):
         # We won't pick GCC if it's the only thing available.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) not in ('clang', 'clang++')
         }
         self.do_toolchain_test(paths, {
@@ -851,7 +851,7 @@
     def test_clang_cl(self):
         # We'll pick clang-cl if msvc can't be found.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) != 'cl'
         }
         self.do_toolchain_test(paths, {
@@ -862,7 +862,7 @@
     def test_gcc(self):
         # We'll pick GCC if msvc and clang-cl can't be found.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) not in ('cl', 'clang-cl')
         }
         self.do_toolchain_test(paths, {
@@ -881,7 +881,7 @@
     def test_clang(self):
         # We'll pick clang if nothing else is found.
         paths = {
-            k: v for k, v in self.PATHS.iteritems()
+            k: v for k, v in self.PATHS.items()
             if os.path.basename(k) not in ('cl', 'clang-cl', 'gcc')
         }
         self.do_toolchain_test(paths, {
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import copy
 import re
@@ -10,7 +10,7 @@
 import unittest
 
 from fnmatch import fnmatch
-from StringIO import StringIO
+from io import StringIO
 from textwrap import dedent
 
 from mozunit import (
@@ -43,7 +43,7 @@
         # Hack around it enough that the configure tests work properly.
         context = self.context
         def normalize_numbers(value):
-            if isinstance(value, types.StringTypes):
+            if isinstance(value, (str,)):
                 if value[-1:] == 'L' and value[:-1].isdigit():
                     value = int(value[:-1])
             return value
@@ -53,7 +53,7 @@
             return self.HAS_FEATURE.sub(r'\1\2', expr)
         self.context = self.Context(
             (normalize_has_feature(k), normalize_numbers(v))
-            for k, v in context.iteritems()
+            for k, v in context.items()
         )
         try:
             return Preprocessor.do_if(self, normalize_has_feature(expression),
@@ -95,7 +95,7 @@
         input.name = 'foo'
         pp.do_include(input)
 
-        self.assertEquals(pp.out.getvalue(), '1 . 2 . c "D"')
+        self.assertEqual(pp.out.getvalue(), '1 . 2 . c "D"')
 
     def test_condition(self):
         pp = CompilerPreprocessor({
@@ -125,7 +125,7 @@
         input.name = 'foo'
         pp.do_include(input)
 
-        self.assertEquals('IFDEF_A\nIF_A\nIF_B\nIF_NOT_C\n', pp.out.getvalue())
+        self.assertEqual('IFDEF_A\nIF_A\nIF_B\nIF_NOT_C\n', pp.out.getvalue())
 
 
 class FakeCompiler(dict):
@@ -164,9 +164,9 @@
     '''
     def __init__(self, *definitions):
         for definition in definitions:
-            if all(not isinstance(d, dict) for d in definition.itervalues()):
+            if all(not isinstance(d, dict) for d in definition.values()):
                 definition = {None: definition}
-            for key, value in definition.iteritems():
+            for key, value in definition.items():
                 self.setdefault(key, {}).update(value)
 
     def __call__(self, stdin, args):
@@ -178,14 +178,14 @@
             pp = CompilerPreprocessor(self[None])
 
             def apply_defn(defn):
-                for k, v in defn.iteritems():
+                for k, v in defn.items():
                     if v is False:
                         if k in pp.context:
                             del pp.context[k]
                     else:
                         pp.context[k] = v
 
-            for glob, defn in self.iteritems():
+            for glob, defn in self.items():
                 if glob and not glob.startswith('-') and fnmatch(file, glob):
                     apply_defn(defn)
 
@@ -216,7 +216,7 @@
                 'A': '1',
                 'B': '2',
             })
-            self.assertEquals(compiler(None, ['-E', 'file']),
+            self.assertEqual(compiler(None, ['-E', 'file']),
                               (0, '1 2 C', ''))
 
             compiler = FakeCompiler({
@@ -238,25 +238,25 @@
                     'B': '42',
                 },
             })
-            self.assertEquals(compiler(None, ['-E', 'file']),
+            self.assertEqual(compiler(None, ['-E', 'file']),
                               (0, '1 2 C', ''))
-            self.assertEquals(compiler(None, ['-E', '-foo', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-foo', 'file']),
                               (0, '1 2 foo', ''))
-            self.assertEquals(compiler(None, ['-E', '-bar', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-bar', 'file']),
                               (0, '1 bar bar', ''))
-            self.assertEquals(compiler(None, ['-E', '-qux', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-qux', 'file']),
                               (0, '1 B C', ''))
-            self.assertEquals(compiler(None, ['-E', '-foo', '-bar', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-foo', '-bar', 'file']),
                               (0, '1 bar bar', ''))
-            self.assertEquals(compiler(None, ['-E', '-bar', '-foo', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-bar', '-foo', 'file']),
                               (0, '1 bar foo', ''))
-            self.assertEquals(compiler(None, ['-E', '-bar', '-qux', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-bar', '-qux', 'file']),
                               (0, '1 B bar', ''))
-            self.assertEquals(compiler(None, ['-E', '-qux', '-bar', 'file']),
+            self.assertEqual(compiler(None, ['-E', '-qux', '-bar', 'file']),
                               (0, '1 bar bar', ''))
-            self.assertEquals(compiler(None, ['-E', 'file.c']),
+            self.assertEqual(compiler(None, ['-E', 'file.c']),
                               (0, '1 42 C', ''))
-            self.assertEquals(compiler(None, ['-E', '-bar', 'file.c']),
+            self.assertEqual(compiler(None, ['-E', '-bar', 'file.c']),
                               (0, '1 bar bar', ''))
 
     def test_multiple_definitions(self):
@@ -267,7 +267,7 @@
             'C': 3,
         })
 
-        self.assertEquals(compiler, {
+        self.assertEqual(compiler, {
             None: {
                 'A': 1,
                 'B': 2,
@@ -282,7 +282,7 @@
             'C': 3,
         })
 
-        self.assertEquals(compiler, {
+        self.assertEqual(compiler, {
             None: {
                 'A': 1,
                 'B': 4,
@@ -302,7 +302,7 @@
             },
         })
 
-        self.assertEquals(compiler, {
+        self.assertEqual(compiler, {
             None: {
                 'A': 1,
                 'B': 4,
@@ -330,7 +330,7 @@
             },
         })
 
-        self.assertEquals(compiler, {
+        self.assertEqual(compiler, {
             None: {
                 'A': 1,
                 'B': 2,
@@ -370,7 +370,7 @@
     def __add__(self, other):
         assert isinstance(other, dict)
         result = copy.deepcopy(self.__dict__)
-        for k, v in other.iteritems():
+        for k, v in other.items():
             if k == 'flags':
                 result.setdefault(k, []).extend(v)
             else:
@@ -381,7 +381,7 @@
 class TestCompilerResult(unittest.TestCase):
     def test_compiler_result(self):
         result = CompilerResult()
-        self.assertEquals(result.__dict__, {
+        self.assertEqual(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath(''),
             'version': '',
@@ -397,7 +397,7 @@
             language='C',
             flags=['-std=gnu99'],
         )
-        self.assertEquals(result.__dict__, {
+        self.assertEqual(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
@@ -407,7 +407,7 @@
         })
 
         result2 = result + {'flags': ['-m32']}
-        self.assertEquals(result2.__dict__, {
+        self.assertEqual(result2.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
@@ -416,14 +416,14 @@
             'flags': ['-std=gnu99', '-m32'],
         })
         # Original flags are untouched.
-        self.assertEquals(result.flags, ['-std=gnu99'])
+        self.assertEqual(result.flags, ['-std=gnu99'])
 
         result3 = result + {
             'compiler': '/usr/bin/gcc-4.7',
             'version': '4.7.3',
             'flags': ['-m32'],
         }
-        self.assertEquals(result3.__dict__, {
+        self.assertEqual(result3.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc-4.7'),
             'version': '4.7.3',
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import os
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_util.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/configure/test_util.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, print_function, unicode_literals
+
 
 import logging
 import os
@@ -11,7 +11,7 @@
 import unittest
 import sys
 
-from StringIO import StringIO
+from io import StringIO
 
 from mozunit import main
 from mozpack import path as mozpath
@@ -434,11 +434,11 @@
         except SystemExit as e:
             status = e.code
 
-        self.assertEquals(status, 0)
+        self.assertEqual(status, 0)
         quote_char = "'"
         if getpreferredencoding().lower() == 'utf-8':
             quote_char = '\u00B4'.encode('utf-8')
-        self.assertEquals(out.getvalue().strip(), quote_char)
+        self.assertEqual(out.getvalue().strip(), quote_char)
 
 
 class TestVersion(unittest.TestCase):
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/controller/test_ccachestats.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/controller/test_ccachestats.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import unittest
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/controller/test_clobber.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/controller/test_clobber.py	(refactored)
@@ -2,14 +2,14 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import shutil
 import tempfile
 import unittest
 
-from StringIO import StringIO
+from io import StringIO
 
 from mozunit import main
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_context.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_context.py	(refactored)
@@ -36,7 +36,7 @@
             'baz': (dict, dict, ''),
         })
 
-        self.assertEqual(test.keys(), [])
+        self.assertEqual(list(test.keys()), [])
 
         self.assertEqual(test['foo'], 0)
 
@@ -84,12 +84,12 @@
             'baz': (dict, list, ''),
         })
 
-        self.assertEqual(test.keys(), [])
+        self.assertEqual(list(test.keys()), [])
 
         with self.assertRaises(ValueError):
             test.update(bar=True, foo={})
 
-        self.assertEqual(test.keys(), [])
+        self.assertEqual(list(test.keys()), [])
 
         test.update(bar=True, foo=1)
 
@@ -258,19 +258,19 @@
         self.assertEqual(lines[-1].strip(), '')
 
     def test_documentation_formatting(self):
-        for typ, inp, doc in VARIABLES.values():
+        for typ, inp, doc in list(VARIABLES.values()):
             self._verify_doc(doc)
 
-        for attr, args, doc in FUNCTIONS.values():
+        for attr, args, doc in list(FUNCTIONS.values()):
             self._verify_doc(doc)
 
-        for func, typ, doc in SPECIAL_VARIABLES.values():
+        for func, typ, doc in list(SPECIAL_VARIABLES.values()):
             self._verify_doc(doc)
 
-        for name, cls in SUBCONTEXTS.items():
+        for name, cls in list(SUBCONTEXTS.items()):
             self._verify_doc(cls.__doc__)
 
-            for name, v in cls.VARIABLES.items():
+            for name, v in list(cls.VARIABLES.items()):
                 self._verify_doc(v[2])
 
 
@@ -631,7 +631,7 @@
 class TestTypedRecord(unittest.TestCase):
 
     def test_fields(self):
-        T = ContextDerivedTypedRecord(('field1', unicode),
+        T = ContextDerivedTypedRecord(('field1', str),
                                       ('field2', list))
         inst = T(None)
         self.assertEqual(inst.field1, '')
@@ -647,7 +647,7 @@
             inst.field3 = []
 
     def test_coercion(self):
-        T = ContextDerivedTypedRecord(('field1', unicode),
+        T = ContextDerivedTypedRecord(('field1', str),
                                       ('field2', list))
         inst = T(None)
         inst.field1 = 3
@@ -673,45 +673,45 @@
     def test_single_bug_component(self):
         c = Context({})
         f = Files(c, pattern='**')
-        f['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         files = {'moz.build': f}
         self.assertEqual(Files.aggregate(files), {
-            'bug_component_counts': [((u'Product1', u'Component1'), 1)],
-            'recommended_bug_component': (u'Product1', u'Component1'),
+            'bug_component_counts': [(('Product1', 'Component1'), 1)],
+            'recommended_bug_component': ('Product1', 'Component1'),
         })
 
     def test_multiple_bug_components(self):
         c = Context({})
         f1 = Files(c, pattern='**')
-        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f1['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         f2 = Files(c, pattern='**')
-        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')
+        f2['BUG_COMPONENT'] = ('Product2', 'Component2')
 
         files = {'a': f1, 'b': f2, 'c': f1}
         self.assertEqual(Files.aggregate(files), {
             'bug_component_counts': [
-                ((u'Product1', u'Component1'), 2),
-                ((u'Product2', u'Component2'), 1),
+                (('Product1', 'Component1'), 2),
+                (('Product2', 'Component2'), 1),
             ],
-            'recommended_bug_component': (u'Product1', u'Component1'),
+            'recommended_bug_component': ('Product1', 'Component1'),
         })
 
     def test_no_recommended_bug_component(self):
         """If there is no clear count winner, we don't recommend a bug component."""
         c = Context({})
         f1 = Files(c, pattern='**')
-        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f1['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         f2 = Files(c, pattern='**')
-        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')
+        f2['BUG_COMPONENT'] = ('Product2', 'Component2')
 
         files = {'a': f1, 'b': f2}
         self.assertEqual(Files.aggregate(files), {
             'bug_component_counts': [
-                ((u'Product1', u'Component1'), 1),
-                ((u'Product2', u'Component2'), 1),
+                (('Product1', 'Component1'), 1),
+                (('Product2', 'Component2'), 1),
             ],
             'recommended_bug_component': None,
         })
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_emitter.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_emitter.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import unittest
@@ -204,7 +204,7 @@
     def test_use_yasm(self):
         # When yasm is not available, this should raise.
         reader = self.reader('use-yasm')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'yasm is not available'):
             self.read_topsrcdir(reader)
 
@@ -267,25 +267,25 @@
         o = objs[0]
         self.assertIsInstance(o, GeneratedFile)
         self.assertEqual(o.outputs, ('bar.c',))
-        self.assertRegexpMatches(o.script, 'script.py$')
+        self.assertRegex(o.script, 'script.py$')
         self.assertEqual(o.method, 'make_bar')
         self.assertEqual(o.inputs, [])
 
     def test_generated_files_no_script(self):
         reader = self.reader('generated-files-no-script')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'Script for generating bar.c does not exist'):
             self.read_topsrcdir(reader)
 
     def test_generated_files_no_inputs(self):
         reader = self.reader('generated-files-no-inputs')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'Input for generating foo.c does not exist'):
             self.read_topsrcdir(reader)
 
     def test_generated_files_no_python_script(self):
         reader = self.reader('generated-files-no-python-script')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'Script for generating bar.c does not end in .py'):
             self.read_topsrcdir(reader)
 
@@ -314,7 +314,7 @@
         Missing files in EXPORTS is an error.
         '''
         reader = self.reader('exports-missing')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'File listed in EXPORTS does not exist:'):
             self.read_topsrcdir(reader)
 
@@ -323,7 +323,7 @@
         An objdir file in EXPORTS that is not in GENERATED_FILES is an error.
         '''
         reader = self.reader('exports-missing-generated')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'Objdir file listed in EXPORTS not in GENERATED_FILES:'):
             self.read_topsrcdir(reader)
 
@@ -360,7 +360,7 @@
 
     def test_test_harness_files_root(self):
         reader = self.reader('test-harness-files-root')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'Cannot install files to the root of TEST_HARNESS_FILES'):
             self.read_topsrcdir(reader)
 
@@ -413,14 +413,14 @@
         """A missing manifest file should result in an error."""
         reader = self.reader('test-manifest-missing-manifest')
 
-        with self.assertRaisesRegexp(BuildReaderError, 'IOError: Missing files'):
+        with self.assertRaisesRegex(BuildReaderError, 'IOError: Missing files'):
             self.read_topsrcdir(reader)
 
     def test_empty_test_manifest_rejected(self):
         """A test manifest without any entries is rejected."""
         reader = self.reader('test-manifest-empty')
 
-        with self.assertRaisesRegexp(SandboxValidationError, 'Empty test manifest'):
+        with self.assertRaisesRegex(SandboxValidationError, 'Empty test manifest'):
             self.read_topsrcdir(reader)
 
 
@@ -428,7 +428,7 @@
         """A test manifest with no tests but support-files is not supported."""
         reader = self.reader('test-manifest-just-support')
 
-        with self.assertRaisesRegexp(SandboxValidationError, 'Empty test manifest'):
+        with self.assertRaisesRegex(SandboxValidationError, 'Empty test manifest'):
             self.read_topsrcdir(reader)
 
     def test_test_manifest_dupe_support_files(self):
@@ -437,7 +437,7 @@
         """
         reader = self.reader('test-manifest-dupes')
 
-        with self.assertRaisesRegexp(SandboxValidationError, 'bar.js appears multiple times '
+        with self.assertRaisesRegex(SandboxValidationError, 'bar.js appears multiple times '
             'in a test manifest under a support-files field, please omit the duplicate entry.'):
             self.read_topsrcdir(reader)
 
@@ -454,7 +454,7 @@
             mozpath.join(o.install_prefix, "absolute-support.ini"),
             mozpath.join(o.install_prefix, "test_file.js"),
         ]
-        paths = sorted([v[0] for v in o.installs.values()])
+        paths = sorted([v[0] for v in list(o.installs.values())])
         self.assertEqual(paths, expected)
 
     @unittest.skip('Bug 1304316 - Items in the second set but not the first')
@@ -481,7 +481,7 @@
         """A non-existent shared support file reference produces an error."""
         reader = self.reader('test-manifest-shared-missing')
 
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
                                      'entry in support-files not present in the srcdir'):
             self.read_topsrcdir(reader)
 
@@ -500,7 +500,7 @@
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/support.txt")),
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/test_foo.html")),
         ]
-        paths = sorted([v[0] for v in o.installs.values()])
+        paths = sorted([v[0] for v in list(o.installs.values())])
         self.assertEqual(paths, expected)
 
     def test_test_manifest_install_includes(self):
@@ -518,7 +518,7 @@
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/mochitest.ini")),
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/test_foo.html")),
         ]
-        paths = sorted([v[0] for v in o.installs.values()])
+        paths = sorted([v[0] for v in list(o.installs.values())])
         self.assertEqual(paths, expected)
 
     def test_test_manifest_includes(self):
@@ -541,7 +541,7 @@
     def test_python_unit_test_missing(self):
         """Missing files in PYTHON_UNIT_TESTS should raise."""
         reader = self.reader('test-python-unit-test-missing')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'Path specified in PYTHON_UNIT_TESTS does not exist:'):
             self.read_topsrcdir(reader)
 
@@ -635,7 +635,7 @@
             self.assertEqual(external_normalized, m.get('external', set()))
 
             self.assertEqual(len(o.installs), len(m['installs']))
-            for path in o.installs.keys():
+            for path in list(o.installs.keys()):
                 self.assertTrue(path.startswith(o.directory))
                 relpath = path[len(o.directory)+1:]
 
@@ -648,7 +648,7 @@
     def test_test_manifest_unmatched_generated(self):
         reader = self.reader('test-manifest-unmatched-generated')
 
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'entry in generated-files not present elsewhere'):
             self.read_topsrcdir(reader),
 
@@ -672,7 +672,7 @@
         """Missing test files should result in error."""
         reader = self.reader('test-manifest-missing-test-file')
 
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'lists test that does not exist: test_missing.html'):
             self.read_topsrcdir(reader)
 
@@ -680,7 +680,7 @@
         """Missing test files should result in error, even when the test list is not filtered."""
         reader = self.reader('test-manifest-missing-test-file-unfiltered')
 
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
             'lists test that does not exist: missing.js'):
             self.read_topsrcdir(reader)
 
@@ -794,20 +794,20 @@
             self.assertIsInstance(obj.path, Path)
 
     def test_jar_manifests_multiple_files(self):
-        with self.assertRaisesRegexp(SandboxValidationError, 'limited to one value'):
+        with self.assertRaisesRegex(SandboxValidationError, 'limited to one value'):
             reader = self.reader('jar-manifests-multiple-files')
             self.read_topsrcdir(reader)
 
     def test_xpidl_module_no_sources(self):
         """XPIDL_MODULE without XPIDL_SOURCES should be rejected."""
-        with self.assertRaisesRegexp(SandboxValidationError, 'XPIDL_MODULE '
+        with self.assertRaisesRegex(SandboxValidationError, 'XPIDL_MODULE '
             'cannot be defined'):
             reader = self.reader('xpidl-module-no-sources')
             self.read_topsrcdir(reader)
 
     def test_missing_local_includes(self):
         """LOCAL_INCLUDES containing non-existent directories should be rejected."""
-        with self.assertRaisesRegexp(SandboxValidationError, 'Path specified in '
+        with self.assertRaisesRegex(SandboxValidationError, 'Path specified in '
             'LOCAL_INCLUDES does not exist'):
             reader = self.reader('missing-local-includes')
             self.read_topsrcdir(reader)
@@ -852,7 +852,7 @@
             '.S': ['g.S'],
             '.s': ['h.s', 'i.asm'],
         }
-        for suffix, files in expected.items():
+        for suffix, files in list(expected.items()):
             sources = suffix_map[suffix]
             self.assertEqual(
                 sources.files,
@@ -905,7 +905,7 @@
             '.S': ['g.S'],
             '.s': ['h.s', 'i.asm'],
         }
-        for suffix, files in expected.items():
+        for suffix, files in list(expected.items()):
             sources = suffix_map[suffix]
             self.assertEqual(
                 sources.files,
@@ -931,7 +931,7 @@
             '.c': ['d.c'],
             '.mm': ['e.mm', 'f.mm'],
         }
-        for suffix, files in expected.items():
+        for suffix, files in list(expected.items()):
             sources = suffix_map[suffix]
             self.assertEqual(
                 sources.files,
@@ -956,7 +956,7 @@
             '.mm': ['objc1.mm', 'objc2.mm'],
             '.c': ['c1.c', 'c2.c'],
         }
-        for suffix, files in expected.items():
+        for suffix, files in list(expected.items()):
             sources = suffix_map[suffix]
             self.assertEqual(
                 sources.files,
@@ -982,7 +982,7 @@
             '.mm': ['objc1.mm', 'objc2.mm'],
             '.c': ['c1.c', 'c2.c'],
         }
-        for suffix, files in expected.items():
+        for suffix, files in list(expected.items()):
             sources = suffix_map[suffix]
             self.assertEqual(
                 sources.files,
@@ -1005,11 +1005,11 @@
 
             expected = {'install.rdf', 'main.js'}
             for f in files:
-                self.assertTrue(unicode(f) in expected)
+                self.assertTrue(str(f) in expected)
 
     def test_missing_final_target_pp_files(self):
         """Test that FINAL_TARGET_PP_FILES with missing files throws errors."""
-        with self.assertRaisesRegexp(SandboxValidationError, 'File listed in '
+        with self.assertRaisesRegex(SandboxValidationError, 'File listed in '
             'FINAL_TARGET_PP_FILES does not exist'):
             reader = self.reader('dist-files-missing')
             self.read_topsrcdir(reader)
@@ -1017,49 +1017,49 @@
     def test_final_target_pp_files_non_srcdir(self):
         '''Test that non-srcdir paths in FINAL_TARGET_PP_FILES throws errors.'''
         reader = self.reader('final-target-pp-files-non-srcdir')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'Only source directory paths allowed in FINAL_TARGET_PP_FILES:'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_no_cargo_toml(self):
         '''Test that defining a RustLibrary without a Cargo.toml fails.'''
         reader = self.reader('rust-library-no-cargo-toml')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'No Cargo.toml file found'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_name_mismatch(self):
         '''Test that defining a RustLibrary that doesn't match Cargo.toml fails.'''
         reader = self.reader('rust-library-name-mismatch')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'library.*does not match Cargo.toml-defined package'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_no_lib_section(self):
         '''Test that a RustLibrary Cargo.toml with no [lib] section fails.'''
         reader = self.reader('rust-library-no-lib-section')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'Cargo.toml for.* has no \\[lib\\] section'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_no_profile_section(self):
         '''Test that a RustLibrary Cargo.toml with no [profile] section fails.'''
         reader = self.reader('rust-library-no-profile-section')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'Cargo.toml for.* has no \\[profile\\.dev\\] section'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_invalid_crate_type(self):
         '''Test that a RustLibrary Cargo.toml has a permitted crate-type.'''
         reader = self.reader('rust-library-invalid-crate-type')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'crate-type.* is not permitted'):
             self.read_topsrcdir(reader)
 
     def test_rust_library_non_abort_panic(self):
         '''Test that a RustLibrary Cargo.toml has `panic = "abort" set'''
         reader = self.reader('rust-library-non-abort-panic')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'does not specify `panic = "abort"`'):
             self.read_topsrcdir(reader)
 
@@ -1072,15 +1072,15 @@
         self.assertEqual(len(objs), 1)
         lib = objs[0]
         self.assertIsInstance(lib, RustLibrary)
-        self.assertRegexpMatches(lib.lib_name, "random_crate")
-        self.assertRegexpMatches(lib.import_name, "random_crate")
-        self.assertRegexpMatches(lib.basename, "random-crate")
+        self.assertRegex(lib.lib_name, "random_crate")
+        self.assertRegex(lib.import_name, "random_crate")
+        self.assertRegex(lib.basename, "random-crate")
 
     def test_multiple_rust_libraries(self):
         '''Test that linking multiple Rust libraries throws an error'''
         reader = self.reader('multiple-rust-libraries',
                              extra_substs=dict(RUST_TARGET='i686-pc-windows-msvc'))
-        with self.assertRaisesRegexp(LinkageMultipleRustLibrariesError,
+        with self.assertRaisesRegex(LinkageMultipleRustLibrariesError,
              'Cannot link multiple Rust libraries'):
             self.read_topsrcdir(reader)
 
@@ -1107,7 +1107,7 @@
             mozpath.join(reader.config.topobjdir, 'dir2'),
             '/dir3',
         ]
-        self.assertEquals([p.full_path for p in objs[0].paths], expected)
+        self.assertEqual([p.full_path for p in objs[0].paths], expected)
 
     def test_binary_components(self):
         """Test that IS_COMPONENT/NO_COMPONENTS_MANIFEST work properly."""
@@ -1163,7 +1163,7 @@
         from GENERATED_FILES is an error.
         """
         reader = self.reader('test-symbols-file-objdir-missing-generated')
-        with self.assertRaisesRegexp(SandboxValidationError,
+        with self.assertRaisesRegex(SandboxValidationError,
              'Objdir file specified in SYMBOLS_FILE not in GENERATED_FILES:'):
             self.read_topsrcdir(reader)
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_namespaces.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_namespaces.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import unittest
 
@@ -29,7 +29,7 @@
 
 class Piyo(ContextDerivedValue):
     def __init__(self, context, value):
-        if not isinstance(value, unicode):
+        if not isinstance(value, str):
             raise ValueError
         self.context = context
         self.value = value
@@ -48,9 +48,9 @@
 
 
 VARIABLES = {
-    'HOGE': (unicode, unicode, None),
-    'FUGA': (Fuga, unicode, None),
-    'PIYO': (Piyo, unicode, None),
+    'HOGE': (str, str, None),
+    'FUGA': (Fuga, str, None),
+    'PIYO': (Piyo, str, None),
     'HOGERA': (ContextDerivedTypedList(Piyo, StrictOrderingOnAppendList),
         list, None),
     'HOGEHOGE': (ContextDerivedTypedListWithItems(
@@ -104,7 +104,7 @@
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'HOGE')
         self.assertEqual(e[3], True)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
     def test_key_checking(self):
         # Checking for existence of a key should not populate the key if it
@@ -127,7 +127,7 @@
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'FUGA')
         self.assertEqual(e[3], False)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
         ns['FUGA'] = 'fuga'
         self.assertIsInstance(ns['FUGA'], Fuga)
@@ -150,7 +150,7 @@
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'PIYO')
         self.assertEqual(e[3], False)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
         ns['PIYO'] = 'piyo'
         self.assertIsInstance(ns['PIYO'], Piyo)
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_reader.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_reader.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import sys
@@ -423,7 +423,7 @@
             'simple/base.cpp',
         ])
 
-        for path, pattern_set in expected.items():
+        for path, pattern_set in list(expected.items()):
             self.assertEqual(v[path].test_files,
                              expected[path])
 
@@ -438,7 +438,7 @@
                                       'default/tests/reftests/**']),
         }
 
-        for path, pattern_set in expected.items():
+        for path, pattern_set in list(expected.items()):
             self.assertEqual(v[path].test_files,
                              expected[path])
 
@@ -454,7 +454,7 @@
             'tagged/src/bar.jsm': set(['tagged/**.js']),
         }
 
-        for path, pattern_set in expected_patterns.items():
+        for path, pattern_set in list(expected_patterns.items()):
             self.assertEqual(v[path].test_files,
                              expected_patterns[path])
 
@@ -462,7 +462,7 @@
             'tagged/src/submodule/foo.js': set(['submodule']),
             'tagged/src/bar.jsm': set([]),
         }
-        for path, pattern_set in expected_tags.items():
+        for path, pattern_set in list(expected_tags.items()):
             self.assertEqual(v[path].test_tags,
                              expected_tags[path])
 
@@ -470,7 +470,7 @@
             'tagged/src/bar.jsm': set(['browser-chrome']),
             'tagged/src/submodule/foo.js': set([]),
         }
-        for path, pattern_set in expected_flavors.items():
+        for path, pattern_set in list(expected_flavors.items()):
             self.assertEqual(v[path].test_flavors,
                              expected_flavors[path])
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_sandbox.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozbuild/test/frontend/test_sandbox.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 import shutil
@@ -345,7 +345,7 @@
         sandbox = MozbuildSandbox(Context(VARIABLES, config))
 
         self.assertEqual(sandbox['CONFIG']['BAD_UTF8'],
-            u'\ufffd\ufffd\ufffd\ufffd:')
+            '\ufffd\ufffd\ufffd\ufffd:')
 
     def test_invalid_exports_set_base(self):
         sandbox = self.sandbox()
@@ -525,7 +525,7 @@
             source = 'a = foo(1, 2)'
             sandbox.exec_source(source, 'foo.mozbuild')
 
-            self.assertEquals(sandbox['a'], (Foo, int))
+            self.assertEqual(sandbox['a'], (Foo, int))
         finally:
             del FUNCTIONS['foo']
 
--- mozjs-52.4.0/python/mozbuild/mozpack/archive.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/archive.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import bz2
 import gzip
--- mozjs-52.4.0/python/mozbuild/mozpack/copier.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/copier.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import stat
@@ -109,7 +109,7 @@
         '''
         Return all paths stored in the container, in the order they were added.
         '''
-        return self._files.keys()
+        return list(self._files.keys())
 
     def __len__(self):
         '''
@@ -142,7 +142,7 @@
             for path, file in registry:
                 (...)
         '''
-        return self._files.iteritems()
+        return iter(self._files.items())
 
     def required_directories(self):
         '''
@@ -151,7 +151,7 @@
         unspecified (virtual) root directory (and do not include said root
         directory).
         '''
-        return set(k for k, v in self._required_directories.items() if v > 0)
+        return set(k for k, v in list(self._required_directories.items()) if v > 0)
 
 
 class FileRegistrySubtree(object):
@@ -263,7 +263,7 @@
 
         Returns a FileCopyResult that details what changed.
         '''
-        assert isinstance(destination, basestring)
+        assert isinstance(destination, str)
         assert not os.path.exists(destination) or os.path.isdir(destination)
 
         result = FileCopyResult()
@@ -531,7 +531,7 @@
             def exists(self):
                 return self.deflater is not None
 
-        if isinstance(dest, basestring):
+        if isinstance(dest, str):
             dest = Dest(dest)
         assert isinstance(dest, Dest)
 
--- mozjs-52.4.0/python/mozbuild/mozpack/errors.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/errors.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import sys
 from contextlib import contextmanager
@@ -97,7 +97,7 @@
             if self._count is None:
                 raise ErrorMessage(msg)
             self._count += 1
-        print >>self.out, msg
+        print(msg, file=self.out)
 
     def fatal(self, msg):
         self._handle(self.FATAL, msg)
--- mozjs-52.4.0/python/mozbuild/mozpack/executables.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/executables.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import os
 import struct
--- mozjs-52.4.0/python/mozbuild/mozpack/files.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/files.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import errno
 import os
@@ -57,7 +57,7 @@
 
     def _copyfile(src, dest):
         # False indicates `dest` should be overwritten if it exists already.
-        if isinstance(src, unicode) and isinstance(dest, unicode):
+        if isinstance(src, str) and isinstance(dest, str):
             _CopyFileW(src, dest, False)
         elif isinstance(src, str) and isinstance(dest, str):
             _CopyFileA(src, dest, False)
@@ -145,13 +145,13 @@
         # - keep file type (e.g. S_IFREG)
         ret = stat.S_IFMT(mode)
         # - expand user read and execute permissions to everyone
-        if mode & 0400:
-            ret |= 0444
-        if mode & 0100:
-            ret |= 0111
+        if mode & 0o400:
+            ret |= 0o444
+        if mode & 0o100:
+            ret |= 0o111
         # - keep user write permissions
-        if mode & 0200:
-            ret |= 0200
+        if mode & 0o200:
+            ret |= 0o200
         # - leave away sticky bit, setuid, setgid
         return ret
 
@@ -164,7 +164,7 @@
         disabled when skip_if_older is False.
         Returns whether a copy was actually performed (True) or not (False).
         '''
-        if isinstance(dest, basestring):
+        if isinstance(dest, str):
             dest = Dest(dest)
         else:
             assert isinstance(dest, Dest)
@@ -258,11 +258,11 @@
     '''
     def copy(self, dest, skip_if_older=True):
         real_dest = dest
-        if not isinstance(dest, basestring):
+        if not isinstance(dest, str):
             fd, dest = mkstemp()
             os.close(fd)
             os.remove(dest)
-        assert isinstance(dest, basestring)
+        assert isinstance(dest, str)
         # If File.copy didn't actually copy because dest is newer, check the
         # file sizes. If dest is smaller, it means it is already stripped and
         # elfhacked, so we can skip.
@@ -299,7 +299,7 @@
         File.__init__(self, path)
 
     def copy(self, dest, skip_if_older=True):
-        assert isinstance(dest, basestring)
+        assert isinstance(dest, str)
 
         # The logic in this function is complicated by the fact that symlinks
         # aren't universally supported. So, where symlinks aren't supported, we
@@ -400,7 +400,7 @@
         self.required = required
 
     def copy(self, dest, skip_if_older=True):
-        if isinstance(dest, basestring):
+        if isinstance(dest, str):
             dest = Dest(dest)
         else:
             assert isinstance(dest, Dest)
@@ -432,7 +432,7 @@
         '''
         Invokes the preprocessor to create the destination file.
         '''
-        if isinstance(dest, basestring):
+        if isinstance(dest, str):
             dest = Dest(dest)
         else:
             assert isinstance(dest, Dest)
@@ -563,7 +563,7 @@
         the individual XPTs to link.
         skip_if_older is ignored.
         '''
-        if isinstance(dest, basestring):
+        if isinstance(dest, str):
             dest = Dest(dest)
         assert isinstance(dest, Dest)
 
@@ -1014,7 +1014,7 @@
         from mozpack.copier import FileRegistry
         self.files = FileRegistry()
 
-        for base, finder in sorted(finders.iteritems()):
+        for base, finder in sorted(finders.items()):
             if self.files.contains(base):
                 self.files.remove(base)
             for p, f in finder.find(''):
--- mozjs-52.4.0/python/mozbuild/mozpack/hg.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/hg.py	(refactored)
@@ -27,7 +27,7 @@
 # do not wish to do so, delete this exception statement from your
 # version.
 
-from __future__ import absolute_import
+
 
 import mercurial.error as error
 import mercurial.hg as hg
@@ -56,7 +56,7 @@
 
         Accepts a Mercurial localrepo and changectx instance.
         """
-        if isinstance(repo, (str, unicode)):
+        if isinstance(repo, str):
             path = repo
             repo = hg.repository(hgui.ui(), repo)
         else:
@@ -85,7 +85,7 @@
         return self._get(path)
 
     def _get(self, path):
-        if isinstance(path, unicode):
+        if isinstance(path, str):
             path = path.encode('utf-8', 'replace')
 
         try:
--- mozjs-52.4.0/python/mozbuild/mozpack/manifests.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/manifests.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import, unicode_literals
+
 
 from contextlib import contextmanager
 import json
--- mozjs-52.4.0/python/mozbuild/mozpack/mozjar.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/mozjar.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 from io import BytesIO
 import struct
@@ -13,8 +13,9 @@
     ZIP_DEFLATED,
 )
 from collections import OrderedDict
-from urlparse import urlparse, ParseResult
+from urllib.parse import urlparse, ParseResult
 import mozpack.path as mozpath
+from functools import reduce
 
 JAR_STORED = ZIP_STORED
 JAR_DEFLATED = ZIP_DEFLATED
@@ -68,7 +69,7 @@
         an instance with empty fields.
         '''
         assert self.MAGIC and isinstance(self.STRUCT, OrderedDict)
-        self.size_fields = set(t for t in self.STRUCT.itervalues()
+        self.size_fields = set(t for t in self.STRUCT.values()
                                if not t in JarStruct.TYPE_MAPPING)
         self._values = {}
         if data:
@@ -90,7 +91,7 @@
         # For all fields used as other fields sizes, keep track of their value
         # separately.
         sizes = dict((t, 0) for t in self.size_fields)
-        for name, t in self.STRUCT.iteritems():
+        for name, t in self.STRUCT.items():
             if t in JarStruct.TYPE_MAPPING:
                 value, size = JarStruct.get_data(t, data[offset:])
             else:
@@ -109,7 +110,7 @@
         Initialize an instance with empty fields.
         '''
         self.signature = self.MAGIC
-        for name, t in self.STRUCT.iteritems():
+        for name, t in self.STRUCT.items():
             if name in self.size_fields:
                 continue
             self._values[name] = 0 if t in JarStruct.TYPE_MAPPING else ''
@@ -134,9 +135,9 @@
         from self.STRUCT.
         '''
         serialized = struct.pack('<I', self.signature)
-        sizes = dict((t, name) for name, t in self.STRUCT.iteritems()
+        sizes = dict((t, name) for name, t in self.STRUCT.items()
                      if not t in JarStruct.TYPE_MAPPING)
-        for name, t in self.STRUCT.iteritems():
+        for name, t in self.STRUCT.items():
             if t in JarStruct.TYPE_MAPPING:
                 format, size = JarStruct.TYPE_MAPPING[t]
                 if name in sizes:
@@ -155,7 +156,7 @@
         variable length fields.
         '''
         size = JarStruct.TYPE_MAPPING['uint32'][1]
-        for name, type in self.STRUCT.iteritems():
+        for name, type in self.STRUCT.items():
             if type in JarStruct.TYPE_MAPPING:
                 size += JarStruct.TYPE_MAPPING[type][1]
             else:
@@ -176,7 +177,7 @@
         return key in self._values
 
     def __iter__(self):
-        return self._values.iteritems()
+        return iter(self._values.items())
 
     def __repr__(self):
         return "<%s %s>" % (self.__class__.__name__,
@@ -374,7 +375,7 @@
             preload = JarStruct.get_data('uint32', self._data)[0]
         entries = OrderedDict()
         offset = self._cdir_end['cdir_offset']
-        for e in xrange(self._cdir_end['cdir_entries']):
+        for e in range(self._cdir_end['cdir_entries']):
             entry = JarCdirEntry(self._data[offset:])
             offset += entry.size
             # Creator host system. 0 is MSDOS, 3 is Unix
@@ -385,7 +386,7 @@
             xattr = entry['external_attr']
             # Skip directories
             if (host == 0 and xattr & 0x10) or (host == 3 and
-                                                xattr & (040000 << 16)):
+                                                xattr & (0o40000 << 16)):
                 continue
             entries[entry['filename']] = entry
             if entry['offset'] < preload:
@@ -436,7 +437,7 @@
             for file in jarReader:
                 ...
         '''
-        for entry in self.entries.itervalues():
+        for entry in self.entries.values():
             yield self._getreader(entry)
 
     def __getitem__(self, name):
@@ -529,7 +530,7 @@
         headers = {}
         preload_size = 0
         # Prepare central directory entries
-        for entry, content in self._contents.itervalues():
+        for entry, content in self._contents.values():
             header = JarLocalFileHeader()
             for name in entry.STRUCT:
                 if name in header:
@@ -544,7 +545,7 @@
         end['disk_entries'] = len(self._contents)
         end['cdir_entries'] = end['disk_entries']
         end['cdir_size'] = reduce(lambda x, y: x + y[0].size,
-                                  self._contents.values(), 0)
+                                  list(self._contents.values()), 0)
         # On optimized archives, store the preloaded size and the central
         # directory entries, followed by the first end of central directory.
         if self._optimize:
@@ -553,18 +554,18 @@
             if preload_size:
                 preload_size += offset
             self._data.write(struct.pack('<I', preload_size))
-            for entry, _ in self._contents.itervalues():
+            for entry, _ in self._contents.values():
                 entry['offset'] += offset
                 self._data.write(entry.serialize())
             self._data.write(end.serialize())
         # Store local file entries followed by compressed data
-        for entry, content in self._contents.itervalues():
+        for entry, content in self._contents.values():
             self._data.write(headers[entry].serialize())
             self._data.write(content)
         # On non optimized archives, store the central directory entries.
         if not self._optimize:
             end['cdir_offset'] = offset
-            for entry, _ in self._contents.itervalues():
+            for entry, _ in self._contents.values():
                 self._data.write(entry.serialize())
         # Store the end of central directory.
         self._data.write(end.serialize())
@@ -599,7 +600,7 @@
             deflater = data
         else:
             deflater = Deflater(compress, compress_level=self._compress_level)
-            if isinstance(data, basestring):
+            if isinstance(data, str):
                 deflater.write(data)
             elif hasattr(data, 'read'):
                 if hasattr(data, 'seek'):
@@ -615,7 +616,7 @@
             # Set creator host system (upper byte of creator_version)
             # to 3 (Unix) so mode is honored when there is one.
             entry['creator_version'] |= 3 << 8
-            entry['external_attr'] = (mode & 0xFFFF) << 16L
+            entry['external_attr'] = (mode & 0xFFFF) << 16
         if deflater.compressed:
             entry['min_version'] = 20  # Version 2.0 supports deflated streams
             entry['general_flag'] = 2  # Max compression
--- mozjs-52.4.0/python/mozbuild/mozpack/path.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/path.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import posixpath
 import os
--- mozjs-52.4.0/python/mozbuild/mozpack/chrome/flags.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/chrome/flags.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import re
 from distutils.version import LooseVersion
@@ -250,7 +250,7 @@
             flags.match(application='foo', appversion='3.5') returns True
             flags.match(application='foo', appversion='3.0') returns False
         '''
-        for name, value in filter.iteritems():
+        for name, value in filter.items():
             if not name in self:
                 continue
             if not self[name].matches(value):
--- mozjs-52.4.0/python/mozbuild/mozpack/chrome/manifest.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/chrome/manifest.py	(refactored)
@@ -2,11 +2,11 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import re
 import os
-from urlparse import urlparse
+from urllib.parse import urlparse
 import mozpack.path as mozpath
 from mozpack.chrome.flags import Flags
 from mozpack.errors import errors
@@ -321,7 +321,7 @@
         return self.serialize(self.contractID, self.cid)
 
 # All manifest classes by their type name.
-MANIFESTS_TYPES = dict([(c.type, c) for c in globals().values()
+MANIFESTS_TYPES = dict([(c.type, c) for c in list(globals().values())
                        if type(c) == type and issubclass(c, ManifestEntry)
                        and hasattr(c, 'type') and c.type])
 
--- mozjs-52.4.0/python/mozbuild/mozpack/packager/__init__.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/packager/__init__.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 from mozbuild.preprocessor import Preprocessor
 import re
@@ -50,7 +50,7 @@
         '''
         Split [1, 2, 3, 4, 5, 6, 7] into [(1, 2, 3), (4, 5, 6)].
         '''
-        return zip(*[iter(lst)] * 3)
+        return list(zip(*[iter(lst)] * 3))
 
     KEY_VALUE_RE = re.compile(r'''
         \s*                 # optional whitespace.
@@ -118,7 +118,7 @@
         destdir = options.pop('destdir', '')
         if options:
             errors.fatal('Malformed manifest: options %s not recognized'
-                         % options.keys())
+                         % list(options.keys()))
         return Component(name, destdir=destdir)
 
 
@@ -328,7 +328,7 @@
 
         bases = self.get_bases()
         broken_bases = sorted(
-            m for m, includer in self._included_manifests.iteritems()
+            m for m, includer in self._included_manifests.items()
             if mozpath.basedir(m, bases) != mozpath.basedir(includer, bases))
         for m in broken_bases:
             errors.fatal('"%s" is included from "%s", which is outside "%s"' %
--- mozjs-52.4.0/python/mozbuild/mozpack/packager/formats.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/packager/formats.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 from mozpack.chrome.manifest import (
     Manifest,
@@ -11,7 +11,7 @@
     ManifestBinaryComponent,
     ManifestResource,
 )
-from urlparse import urlparse
+from urllib.parse import urlparse
 import mozpack.path as mozpath
 from mozpack.files import (
     ManifestFile,
@@ -89,7 +89,7 @@
         Return the deepest base directory containing the given path.
         '''
         self._frozen_bases = True
-        base = mozpath.basedir(path, self._sub_formatter.keys())
+        base = mozpath.basedir(path, list(self._sub_formatter.keys()))
         relpath = mozpath.relpath(path, base) if base else path
         return base, relpath
 
--- mozjs-52.4.0/python/mozbuild/mozpack/packager/l10n.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/packager/l10n.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 '''
 Replace localized parts of a packaged directory with data from a langpack
@@ -162,7 +162,7 @@
             if not path:
                 continue
         else:
-            base = mozpath.basedir(p, paths.keys())
+            base = mozpath.basedir(p, list(paths.keys()))
             if base:
                 subpath = mozpath.relpath(p, base)
                 path = mozpath.normpath(mozpath.join(paths[base],
@@ -206,7 +206,7 @@
                     formatter.add(p, f)
 
     # Transplant jar preloading information.
-    for path, log in app_finder.jarlogs.iteritems():
+    for path, log in app_finder.jarlogs.items():
         assert isinstance(copier[path], Jarrer)
         copier[path].preload([l.replace(locale, l10n_locale) for l in log])
 
@@ -237,7 +237,7 @@
         finders = {
             '': l10n_finder,
         }
-        for base, path in extra_l10n.iteritems():
+        for base, path in extra_l10n.items():
             finders[base] = UnpackFinder(path)
         l10n_finder = ComposedFinder(finders)
     copier = FileCopier()
--- mozjs-52.4.0/python/mozbuild/mozpack/packager/unpack.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/packager/unpack.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import mozpack.path as mozpath
 from mozpack.files import (
@@ -27,7 +27,7 @@
     FlatFormatter,
     STARTUP_CACHE_PATHS,
 )
-from urlparse import urlparse
+from urllib.parse import urlparse
 
 
 class UnpackFinder(BaseFinder):
@@ -149,7 +149,7 @@
         if not any(f.compressed for f in jar):
             self.compressed = False
         if jar.last_preloaded:
-            jarlog = jar.entries.keys()
+            jarlog = list(jar.entries.keys())
             self.jarlogs[path] = jarlog[:jarlog.index(jar.last_preloaded) + 1]
         return jar
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_archive.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_archive.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import absolute_import
+
 
 import hashlib
 import os
@@ -69,7 +69,7 @@
         try:
             tp = os.path.join(d, 'test.tar')
             with open(tp, 'wb') as fh:
-                with self.assertRaisesRegexp(ValueError, 'not a regular'):
+                with self.assertRaisesRegex(ValueError, 'not a regular'):
                     create_tar_from_files(fh, {'test': d})
         finally:
             shutil.rmtree(d)
@@ -89,9 +89,9 @@
 
             tp = os.path.join(d, 'test.tar')
             with open(tp, 'wb') as fh:
-                with self.assertRaisesRegexp(ValueError, 'cannot add file with setuid'):
+                with self.assertRaisesRegex(ValueError, 'cannot add file with setuid'):
                     create_tar_from_files(fh, {'test': uid})
-                with self.assertRaisesRegexp(ValueError, 'cannot add file with setuid'):
+                with self.assertRaisesRegex(ValueError, 'cannot add file with setuid'):
                     create_tar_from_files(fh, {'test': gid})
         finally:
             shutil.rmtree(d)
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_chrome_manifest.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_chrome_manifest.py	(refactored)
@@ -24,7 +24,7 @@
     parse_manifest_line,
 )
 from mozpack.errors import errors, AccumulatedErrors
-from test_errors import TestErrors
+from .test_errors import TestErrors
 
 
 class TestManifest(unittest.TestCase):
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_copier.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_copier.py	(refactored)
@@ -127,7 +127,7 @@
             'bar': [],
         }
         reg = FileRegistry()
-        for path, parts in cases.iteritems():
+        for path, parts in cases.items():
             self.assertEqual(reg._partial_paths(path), parts)
 
     def test_file_registry(self):
@@ -414,7 +414,7 @@
         self.assertTrue(stat.S_ISDIR(st.st_mode))
 
         # What's worse, we have no record that dest was created.
-        self.assertEquals(len(result.updated_files), 0)
+        self.assertEqual(len(result.updated_files), 0)
 
         # But we do have an erroneous record of an optional file
         # existing when it does not.
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_errors.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_errors.py	(refactored)
@@ -10,7 +10,7 @@
 import unittest
 import mozunit
 import sys
-from cStringIO import StringIO
+from io import StringIO
 
 
 class TestErrors(object):
@@ -30,14 +30,14 @@
         errors.warn('foo')
         self.assertRaises(ErrorMessage, errors.error, 'foo')
         self.assertRaises(ErrorMessage, errors.fatal, 'foo')
-        self.assertEquals(self.get_output(), ['Warning: foo'])
+        self.assertEqual(self.get_output(), ['Warning: foo'])
 
     def test_ignore_errors(self):
         errors.ignore_errors()
         errors.warn('foo')
         errors.error('bar')
         self.assertRaises(ErrorMessage, errors.fatal, 'foo')
-        self.assertEquals(self.get_output(), ['Warning: foo', 'Warning: bar'])
+        self.assertEqual(self.get_output(), ['Warning: foo', 'Warning: bar'])
 
     def test_no_error(self):
         with errors.accumulate():
@@ -47,14 +47,14 @@
         with self.assertRaises(AccumulatedErrors):
             with errors.accumulate():
                 errors.error('1')
-        self.assertEquals(self.get_output(), ['Error: 1'])
+        self.assertEqual(self.get_output(), ['Error: 1'])
 
     def test_error_loop(self):
         with self.assertRaises(AccumulatedErrors):
             with errors.accumulate():
                 for i in range(3):
                     errors.error('%d' % i)
-        self.assertEquals(self.get_output(),
+        self.assertEqual(self.get_output(),
                           ['Error: 0', 'Error: 1', 'Error: 2'])
 
     def test_multiple_errors(self):
@@ -67,7 +67,7 @@
                     else:
                         errors.error('%d' % i)
                 errors.error('bar')
-        self.assertEquals(self.get_output(),
+        self.assertEqual(self.get_output(),
                           ['Error: foo', 'Error: 0', 'Error: 1',
                            'Warning: 2', 'Error: bar'])
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_files.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_files.py	(refactored)
@@ -61,7 +61,7 @@
 import mozpack.path as mozpath
 from tempfile import mkdtemp
 from io import BytesIO
-from StringIO import StringIO
+from io import StringIO
 from xpt import Typelib
 
 
@@ -146,7 +146,7 @@
         dest.write('qux')
         self.assertEqual(dest.read(), 'qux')
 
-rand = ''.join(random.choice(string.letters) for i in xrange(131597))
+rand = ''.join(random.choice(string.letters) for i in range(131597))
 samples = [
     '',
     'test',
@@ -268,7 +268,7 @@
     def test_absolute_relative(self):
         AbsoluteSymlinkFile('/foo')
 
-        with self.assertRaisesRegexp(ValueError, 'Symlink target not absolute'):
+        with self.assertRaisesRegex(ValueError, 'Symlink target not absolute'):
             AbsoluteSymlinkFile('./foo')
 
     def test_symlink_file(self):
@@ -477,7 +477,7 @@
 
 class TestExistingFile(TestWithTmpDir):
     def test_required_missing_dest(self):
-        with self.assertRaisesRegexp(ErrorMessage, 'Required existing file'):
+        with self.assertRaisesRegex(ErrorMessage, 'Required existing file'):
             f = ExistingFile(required=True)
             f.copy(self.tmppath('dest'))
 
@@ -566,7 +566,7 @@
         with JarWriter(src) as jar:
             for content in samples:
                 name = ''.join(random.choice(string.letters)
-                               for i in xrange(8))
+                               for i in range(8))
                 jar.add(name, content, compress=True)
                 contents[name] = content
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_manifests.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_manifests.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import unicode_literals
+
 
 import os
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_mozjar.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_mozjar.py	(refactored)
@@ -16,8 +16,8 @@
 from mozpack.test.test_files import MockDest
 import unittest
 import mozunit
-from cStringIO import StringIO
-from urllib import pathname2url
+from io import StringIO
+from urllib.request import pathname2url
 import mozpack.path as mozpath
 import os
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_packager_formats.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_packager_formats.py	(refactored)
@@ -128,7 +128,7 @@
                 'foo': read_interfaces(foo2_xpt.open())['foo'],
                 'bar': read_interfaces(bar_xpt.open())['bar'],
             },
-        }.iteritems()
+        }.items()
     })
 
 RESULT_JAR = {
@@ -174,7 +174,7 @@
     },
     'addon1.xpi': {
         mozpath.relpath(p, 'addon1'): f
-        for p, f in RESULT_FLAT.iteritems()
+        for p, f in RESULT_FLAT.items()
         if p.startswith('addon1/')
     },
 })
@@ -234,7 +234,7 @@
 CONTENTS_WITH_BASE = {
     'bases': {
         mozpath.join('base/root', b) if b else 'base/root': a
-        for b, a in CONTENTS['bases'].iteritems()
+        for b, a in CONTENTS['bases'].items()
     },
     'manifests': [
         m.move(mozpath.join('base/root', m.base))
@@ -242,7 +242,7 @@
     ],
     'files': {
         mozpath.join('base/root', p): f
-        for p, f in CONTENTS['files'].iteritems()
+        for p, f in CONTENTS['files'].items()
     },
 }
 
@@ -255,7 +255,7 @@
 def result_with_base(results):
     result = {
         mozpath.join('base/root', p): v
-        for p, v in results.iteritems()
+        for p, v in results.items()
     }
     result.update(EXTRA_CONTENTS)
     return result
@@ -271,13 +271,13 @@
 
 
 def fill_formatter(formatter, contents):
-    for base, is_addon in contents['bases'].items():
+    for base, is_addon in list(contents['bases'].items()):
         formatter.add_base(base, is_addon)
 
     for manifest in contents['manifests']:
         formatter.add_manifest(manifest)
 
-    for k, v in contents['files'].iteritems():
+    for k, v in contents['files'].items():
         if k.endswith('.xpt'):
             formatter.add_interfaces(k, v)
         else:
--- mozjs-52.4.0/python/mozbuild/mozpack/test/test_packager_l10n.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/test_packager_l10n.py	(refactored)
@@ -4,7 +4,7 @@
 
 import unittest
 import mozunit
-from test_packager import MockFinder
+from .test_packager import MockFinder
 from mozpack.packager import l10n
 from mozpack.files import (
     GeneratedFile,
@@ -118,7 +118,7 @@
 
         self.assertEqual(
             dict((p, f.open().read()) for p, f in copier),
-            dict((p, f.open().read()) for p, f in repacked.iteritems())
+            dict((p, f.open().read()) for p, f in repacked.items())
         )
 
 
--- mozjs-52.4.0/python/mozbuild/mozpack/test/support/minify_js_verify.py	(original)
+++ mozjs-52.4.0/python/mozbuild/mozpack/test/support/minify_js_verify.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import print_function
+
 import sys
 
 
--- mozjs-52.4.0/build/moz.configure/keyfiles.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/keyfiles.configure	2018-07-10 07:57:16.030000000 +0000
@@ -16,8 +16,8 @@
 
     @depends('--with-%s-keyfile' % name)
     @checking('for the %s key' % desc, lambda x: x and x is not no_key)
-    @imports(_from='__builtin__', _import='open')
-    @imports(_from='__builtin__', _import='IOError')
+    @imports(_from='builtins', _import='open')
+    @imports(_from='builtins', _import='IOError')
     def keyfile(value):
         if value:
             try:
--- mozjs-52.4.0/build/moz.configure/windows.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/windows.configure	2018-07-10 07:57:25.210000000 +0000
@@ -19,7 +19,7 @@
 
 
 @depends_win('--with-windows-version')
-@imports(_from='__builtin__', _import='ValueError')
+@imports(_from='builtins', _import='ValueError')
 def valid_windows_version(value):
     if not value:
         die('Cannot build with --without-windows-version')
@@ -56,8 +56,8 @@
 # 8.1.
 @imports('os')
 @imports('re')
-@imports(_from='__builtin__', _import='sorted')
-@imports(_from='__builtin__', _import='WindowsError')
+@imports(_from='builtins', _import='sorted')
+@imports(_from='builtins', _import='WindowsError')
 def get_sdk_dirs(sdk, subdir):
     def get_dirs_containing(sdk, stem, subdir):
         base = os.path.join(sdk, stem)
@@ -102,7 +102,7 @@
 @depends_win(c_compiler, windows_sdk_dir, valid_windows_version,
              'WINDOWSSDKDIR')
 @checking('for Windows SDK', valid_windows_sdk_dir_result)
-@imports(_from='__builtin__', _import='sorted')
+@imports(_from='builtins', _import='sorted')
 @imports(_from='textwrap', _import='dedent')
 def valid_windows_sdk_dir(compiler, windows_sdk_dir, target_version,
                           windows_sdk_dir_env):
@@ -179,7 +179,7 @@
 @depends_win(windows_sdk_dir, 'WINDOWSSDKDIR')
 @checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result)
 @imports('os')
-@imports(_from='__builtin__', _import='sorted')
+@imports(_from='builtins', _import='sorted')
 @imports(_import='mozpack.path', _as='mozpath')
 def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env):
     if windows_sdk_dir_env:
--- mozjs-52.4.0/build/moz.configure/toolchain.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/toolchain.configure	2018-07-10 07:57:28.830000000 +0000
@@ -395,7 +395,7 @@
 
 
 @imports(_from='collections', _import='defaultdict')
-@imports(_from='__builtin__', _import='sorted')
+@imports(_from='builtins', _import='sorted')
 def get_vc_paths(base):
     vc = defaultdict(lambda: defaultdict(dict))
     subkey = r'Microsoft\VisualStudio\VC\*\*\*\Compiler'
--- mozjs-52.4.0/build/moz.configure/util.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/util.configure	2018-07-10 07:57:31.540000000 +0000
@@ -234,7 +234,7 @@
 #     ('19.0', 'x64', r'C:\...\amd64\cl.exe')
 #     ('19.0', 'x86', r'C:\...\amd64_x86\cl.exe')
 @imports(_import='_winreg', _as='winreg')
-@imports(_from='__builtin__', _import='WindowsError')
+@imports(_from='builtins', _import='WindowsError')
 @imports(_from='fnmatch', _import='fnmatch')
 def get_registry_values(pattern):
     def enum_helper(func, key):
--- mozjs-52.4.0/build/moz.configure/checks.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/checks.configure	2018-07-10 07:57:35.630000000 +0000
@@ -12,7 +12,7 @@
 # _declare_exceptions template, and add it to the return statement. Then
 # destructure in the assignment below the function declaration.
 @template
-@imports(_from='__builtin__', _import='Exception')
+@imports(_from='builtins', _import='Exception')
 def _declare_exceptions():
     class FatalCheckError(Exception):
         '''An exception to throw from a function decorated with @checking.
--- mozjs-52.4.0/build/moz.configure/old.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/old.configure	2018-07-10 07:57:38.970000000 +0000
@@ -61,8 +61,8 @@
 
 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
          old_configure_assignments, build_project)
-@imports(_from='__builtin__', _import='open')
-@imports(_from='__builtin__', _import='print')
+@imports(_from='builtins', _import='open')
+@imports(_from='builtins', _import='print')
 @imports('glob')
 @imports('itertools')
 @imports('subprocess')
@@ -302,8 +302,8 @@
     '--enable-calendar',
     '--enable-incomplete-external-linkage',
 )
-@imports(_from='__builtin__', _import='compile')
-@imports(_from='__builtin__', _import='open')
+@imports(_from='builtins', _import='compile')
+@imports(_from='builtins', _import='open')
 @imports('logging')
 @imports('os')
 @imports('subprocess')
--- mozjs-52.4.0/build/moz.configure/android-ndk.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/android-ndk.configure	2018-07-10 07:57:41.120000000 +0000
@@ -22,7 +22,7 @@
           default=min_android_version)
 
 @depends('--with-android-version', min_android_version)
-@imports(_from='__builtin__', _import='ValueError')
+@imports(_from='builtins', _import='ValueError')
 def android_version(value, min_version):
     if not value:
         # Someone has passed --without-android-version.
--- mozjs-52.4.0/build/moz.configure/init.configure.old	2017-04-11 02:13:08.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/init.configure	2018-07-10 07:57:44.330000000 +0000
@@ -636,7 +636,7 @@
 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
 # - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
 @depends(check_build_environment, '--help')
-@imports(_from='__builtin__', _import='open')
+@imports(_from='builtins', _import='open')
 def milestone(build_env, _):
     milestone_path = os.path.join(build_env.topsrcdir,
                                   'config',
diff -aur mozjs-52.4.0/config/mozunit.py mozjs-fixed/config/mozunit.py
--- mozjs-52.4.0/config/mozunit.py	2017-04-11 02:13:09.000000000 +0000
+++ mozjs-fixed/config/mozunit.py	2018-07-10 08:19:37.770000000 +0000
@@ -5,7 +5,7 @@
 from unittest import TextTestRunner as _TestRunner, TestResult as _TestResult
 import unittest
 import inspect
-from StringIO import StringIO
+from io import StringIO
 import os
 import sys
 
@@ -74,7 +74,7 @@
 
     def printFail(self, test, err):
         exctype, value, tb = err
-        message = value.message.splitlines()[0] if value.message else 'NO MESSAGE'
+        message = str(value).splitlines()[0] if str(value) else 'NO MESSAGE'
         # Skip test runner traceback levels
         while tb and self._is_relevant_tb_level(tb):
             tb = tb.tb_next
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/backend/configenvironment.py mozjs-fixed/python/mozbuild/mozbuild/backend/configenvironment.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/configenvironment.py	2018-07-10 08:24:43.150000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/backend/configenvironment.py	2018-07-10 08:15:12.650000000 +0000
@@ -8,7 +8,8 @@
 import sys
 
 from collections import Iterable
-from types import StringTypes, ModuleType
+from types import ModuleType
+StringTypes = (str,)
 
 import mozpack.path as mozpath
 
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/makeutil.py mozjs-fixed/python/mozbuild/mozbuild/makeutil.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/makeutil.py	2018-07-10 08:24:43.150000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/makeutil.py	2018-07-10 08:20:05.230000000 +0000
@@ -6,7 +6,6 @@
 
 import os
 import re
-from types import StringTypes
 from collections import Iterable
 
 
@@ -103,19 +102,19 @@
 
     def add_targets(self, targets):
         '''Add additional targets to the rule.'''
-        assert isinstance(targets, Iterable) and not isinstance(targets, StringTypes)
+        assert isinstance(targets, Iterable) and not isinstance(targets, str)
         self._targets.update(targets)
         return self
 
     def add_dependencies(self, deps):
         '''Add dependencies to the rule.'''
-        assert isinstance(deps, Iterable) and not isinstance(deps, StringTypes)
+        assert isinstance(deps, Iterable) and not isinstance(deps, str)
         self._dependencies.update(deps)
         return self
 
     def add_commands(self, commands):
         '''Add commands to the rule.'''
-        assert isinstance(commands, Iterable) and not isinstance(commands, StringTypes)
+        assert isinstance(commands, Iterable) and not isinstance(commands, str)
         self._commands.extend(commands)
         return self
 
diff -aur mozjs-52.4.0/testing/mozbase/mozprocess/mozprocess/processhandler.py mozjs-fixed/testing/mozbase/mozprocess/mozprocess/processhandler.py
--- mozjs-52.4.0/testing/mozbase/mozprocess/mozprocess/processhandler.py	2017-04-11 02:13:06.000000000 +0000
+++ mozjs-fixed/testing/mozbase/mozprocess/mozprocess/processhandler.py	2018-07-10 08:13:15.440000000 +0000
@@ -11,7 +11,7 @@
 import threading
 import time
 import traceback
-from Queue import Queue, Empty
+from queue import Queue, Empty
 from datetime import datetime
 
 __all__ = ['ProcessHandlerMixin', 'ProcessHandler', 'LogOutput',
@@ -121,14 +121,14 @@
             thread = threading.current_thread().name
             print("DBG::MOZPROC PID:{} ({}) | {}".format(self.pid, thread, msg))
 
-        def __del__(self, _maxint=sys.maxint):
+        def __del__(self, _maxint=sys.maxsize):
             if isWin:
                 handle = getattr(self, '_handle', None)
                 if handle:
                     if hasattr(self, '_internal_poll'):
                         self._internal_poll(_deadstate=_maxint)
                     else:
-                        self.poll(_deadstate=sys.maxint)
+                        self.poll(_deadstate=sys.maxsize)
                 if handle or self._job or self._io_port:
                     self._cleanup()
             else:
@@ -267,7 +267,7 @@
                 if not (can_create_job or can_nest_jobs):
                     # Since we've warned, we just log info here to inform you
                     # of the consequence of setting ignore_children = True
-                    print "ProcessManager NOT managing child processes"
+                    print("ProcessManager NOT managing child processes")
 
                 # create the process
                 hp, ht, pid, tid = winprocess.CreateProcess(
@@ -534,11 +534,11 @@
 
                     if rc == winprocess.WAIT_TIMEOUT:
                         # The process isn't dead, so kill it
-                        print "Timed out waiting for process to close, attempting TerminateProcess"
+                        print("Timed out waiting for process to close, attempting TerminateProcess")
                         self.kill()
                     elif rc == winprocess.WAIT_OBJECT_0:
                         # We caught WAIT_OBJECT_0, which indicates all is well
-                        print "Single process terminated successfully"
+                        print("Single process terminated successfully")
                         self.returncode = winprocess.GetExitCodeProcess(self._handle)
                     else:
                         # An error occured we should probably throw
diff -aur mozjs-52.4.0/build/moz.configure/checks.configure mozjs-fixed/build/moz.configure/checks.configure
--- mozjs-52.4.0/build/moz.configure/checks.configure	2018-07-10 10:29:50.380000000 +0000
+++ mozjs-fixed/build/moz.configure/checks.configure	2018-07-10 10:27:45.350000000 +0000
@@ -52,7 +52,7 @@
                 try:
                     ret = func(*args, **kwargs)
                 except FatalCheckError as e:
-                    error = e.message
+                    error = str(e)
                 display_ret = callback(ret) if callback else ret
                 if display_ret is True:
                     log.info('yes')
diff -aur mozjs-52.4.0/build/moz.configure/init.configure mozjs-fixed/build/moz.configure/init.configure
--- mozjs-52.4.0/build/moz.configure/init.configure	2018-07-10 10:29:50.380000000 +0000
+++ mozjs-fixed/build/moz.configure/init.configure	2018-07-10 10:23:19.960000000 +0000
@@ -213,7 +213,7 @@
     def early_options():
         return set(
             option.env
-            for option in __sandbox__._options.itervalues()
+            for option in list(__sandbox__._options.values())
             if option.env
         )
     return early_options
@@ -297,7 +297,7 @@
     # There is also a quartet form:
     #   CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
     # But we can consider the "KERNEL-OPERATING_SYSTEM" as one.
-    cpu, manufacturer, os = triplet.split('-', 2)
+    cpu, manufacturer, os = triplet.decode('utf-8').split('-', 2)
 
     # Autoconf uses config.sub to validate and canonicalize those triplets,
     # but the granularity of its results has never been satisfying to our
@@ -727,7 +727,7 @@
 def all_configure_options(_):
     result = []
     previous = None
-    for option in __sandbox__._options.itervalues():
+    for option in list(__sandbox__._options.values()):
         # __sandbox__._options contains items for both option.name and
         # option.env. But it's also an OrderedDict, meaning both are
         # consecutive.
diff -aur mozjs-52.4.0/build/moz.configure/old.configure mozjs-fixed/build/moz.configure/old.configure
--- mozjs-52.4.0/build/moz.configure/old.configure	2018-07-10 10:29:50.380000000 +0000
+++ mozjs-fixed/build/moz.configure/old.configure	2018-07-10 10:19:19.880000000 +0000
@@ -360,7 +360,7 @@
         # Every variation of the exec() function I tried led to:
         # SyntaxError: unqualified exec is not allowed in function 'main' it
         # contains a nested function with free variables
-        exec code in raw_config
+        exec(code, raw_config)
 
     # Ensure all the flags known to old-configure appear in the
     # @old_configure_options above.
diff -aur mozjs-52.4.0/build/moz.configure/toolchain.configure mozjs-fixed/build/moz.configure/toolchain.configure
--- mozjs-52.4.0/build/moz.configure/toolchain.configure	2018-07-10 10:29:50.380000000 +0000
+++ mozjs-fixed/build/moz.configure/toolchain.configure	2018-07-10 10:28:13.020000000 +0000
@@ -244,7 +244,7 @@
         ('CPU', CPU_preprocessor_checks),
         ('KERNEL', kernel_preprocessor_checks),
     ):
-        for n, (value, condition) in enumerate(preprocessor_checks.iteritems()):
+        for n, (value, condition) in enumerate(preprocessor_checks.items()):
             check += dedent('''\
                 #%(if)s %(condition)s
                 %%%(name)s "%(value)s"
@@ -278,9 +278,9 @@
     data = {}
     for line in result.splitlines():
         if line.startswith(b'%'):
-            k, _, v = line.partition(' ')
-            k = k.lstrip('%')
-            data[k] = v.replace(' ', '').lstrip('"').rstrip('"')
+            k, _, v = line.partition(b' ')
+            k = k.lstrip(b'%').decode('utf-8')
+            data[k] = v.replace(b' ', b'').lstrip(b'"').rstrip(b'"').decode('utf-8')
             log.debug('%s = %s', k, data[k])
 
     try:
diff -aur mozjs-52.4.0/build/moz.configure/util.configure mozjs-fixed/build/moz.configure/util.configure
--- mozjs-52.4.0/build/moz.configure/util.configure	2018-07-10 10:29:50.380000000 +0000
+++ mozjs-fixed/build/moz.configure/util.configure	2018-07-10 10:23:54.980000000 +0000
@@ -299,6 +299,8 @@
 @imports(_from='mozbuild.configure.util', _import='Version', _as='_Version')
 def Version(v):
     'A version number that can be compared usefully.'
+    if isinstance(v, bytes):
+    	v = v.decode('utf-8')
     return _Version(v)
 
 # Denotes a deprecated option. Combines option() and @depends:
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/configure/__init__.py mozjs-fixed/python/mozbuild/mozbuild/configure/__init__.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/__init__.py	2018-07-10 10:29:50.350000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/configure/__init__.py	2018-07-10 10:24:33.200000000 +0000
@@ -97,6 +97,9 @@
             ', '.join(repr(d) for d in self.dependencies),
         )
 
+    def __hash__(self):
+        return hash((str(self.func), tuple(self.dependencies), self.when))
+
 
 class CombinedDependsFunction(DependsFunction):
     def __init__(self, sandbox, func, dependencies):
@@ -142,6 +145,9 @@
     def __ne__(self, other):
         return not self == other
 
+    def __hash__(self):
+        return hash((str(self.func), tuple(self.dependencies)))
+
 class SandboxedGlobal(dict):
     '''Identifiable dict type for use as function global'''
 
@@ -192,7 +198,8 @@
         b: __builtins__[b]
         for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
                   'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
-                  'hasattr', 'enumerate', 'range', 'zip')
+                  'hasattr', 'enumerate', 'range', 'zip', '__build_class__',
+                  'bytes', 'exec')
     }, __import__=forbidden_import, str=str)
 
     # Expose a limited set of functions from os.path
@@ -267,7 +274,7 @@
                 return method
             def wrapped(*args, **kwargs):
                 out_args = [
-                    arg.decode(encoding) if isinstance(arg, str) else arg
+                    arg.decode(encoding) if isinstance(arg, bytes) else arg
                     for arg in args
                 ]
                 return method(*out_args, **kwargs)
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/configure/options.py mozjs-fixed/python/mozbuild/mozbuild/configure/options.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/options.py	2018-07-10 10:29:50.350000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/configure/options.py	2018-07-10 10:15:41.760000000 +0000
@@ -65,6 +65,9 @@
         return '%s%s' % (self.__class__.__name__,
                          super(OptionValue, self).__repr__())
 
+    def __hash__(self):
+        return hash(str(self))
+
 
 class PositiveOptionValue(OptionValue):
     '''Represents the value for a positive option (--enable/--with/--foo)
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/configure/util.py mozjs-fixed/python/mozbuild/mozbuild/configure/util.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/configure/util.py	2018-07-10 10:29:50.350000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/configure/util.py	2018-07-10 09:04:28.150000000 +0000
@@ -200,7 +200,7 @@
         self._encoding = getpreferredencoding()
 
     def write(self, buf):
-        if self._encoding and isinstance(buf, str):
+        if self._encoding and isinstance(buf, bytes):
             buf = buf.decode(self._encoding)
         lines = buf.splitlines()
         if not lines:
diff -aur mozjs-52.4.0/python/mozbuild/mozbuild/virtualenv.py mozjs-fixed/python/mozbuild/mozbuild/virtualenv.py
--- mozjs-52.4.0/python/mozbuild/mozbuild/virtualenv.py	2018-07-10 10:29:50.350000000 +0000
+++ mozjs-fixed/python/mozbuild/mozbuild/virtualenv.py	2018-07-10 10:11:47.710000000 +0000
@@ -108,7 +108,7 @@
         """
         ver = subprocess.check_output([python, '-c', 'import sys; print(sys.hexversion)']).rstrip()
         with open(self.exe_info_path, 'w') as fh:
-            fh.write("%s\n" % ver)
+            fh.write("%s\n" % ver.decode('utf-8'))
             fh.write("%s\n" % os.path.getsize(python))
 
     def up_to_date(self, python=sys.executable):
@@ -207,7 +207,7 @@
         return self.virtualenv_root
 
     def packages(self):
-        with file(self.manifest_path, 'rU') as fh:
+        with open(self.manifest_path, 'rU') as fh:
             packages = [line.rstrip().split(':')
                         for line in fh]
         return packages
@@ -530,9 +530,9 @@
 
     our = LooseVersion('%d.%d.%d' % (major, minor, micro))
 
-    if major != MINIMUM_PYTHON_MAJOR or our < MINIMUM_PYTHON_VERSION:
-        log_handle.write('Python %s or greater (but not Python 3) is '
-            'required to build. ' % MINIMUM_PYTHON_VERSION)
+    if our < MINIMUM_PYTHON_VERSION:
+        log_handle.write('Python %s or greater is required to build. '
+            % MINIMUM_PYTHON_VERSION)
         log_handle.write('You are running Python %s.\n' % our)
 
         if os.name in ('nt', 'ce'):
--- mozjs-52.4.0/build/moz.configure/old.configure.old	2018-07-10 10:32:48.550000000 +0000
+++ mozjs-52.4.0/build/moz.configure/old.configure	2018-07-10 10:35:32.440000000 +0000
@@ -107,7 +107,7 @@
 
         # Make old-configure append to config.log, where we put our own log.
         # This could be done with a m4 macro, but it's way easier this way
-        script = script.replace('>./config.log', '>>./config.log')
+        script = script.replace(b'>./config.log', b'>>./config.log')
 
         with open(old_configure, 'wb') as fh:
             fh.write(script)
--- mozjs-52.4.0/build/subconfigure.py.old	2017-04-11 02:13:09.000000000 +0000
+++ mozjs-52.4.0/build/subconfigure.py	2018-07-10 10:38:08.910000000 +0000
@@ -27,7 +27,7 @@
             return super(Pool, cls).__new__(cls)
 
     def imap_unordered(self, fn, iterable):
-        return itertools.imap(fn, iterable)
+        return map(fn, iterable)
 
     def close(self):
         pass
@@ -131,11 +131,11 @@
         is_set = cache.get('ac_cv_env_%s_set' % precious) == 'set'
         value = cache.get('ac_cv_env_%s_value' % precious) if is_set else None
         if value != env.get(precious):
-            print 'Removing %s because of %s value change from:' \
-                % (data['cache-file'], precious)
-            print '  %s' % (value if value is not None else 'undefined')
-            print 'to:'
-            print '  %s' % env.get(precious, 'undefined')
+            print('Removing %s because of %s value change from:' \
+                % (data['cache-file'], precious))
+            print('  %s' % (value if value is not None else 'undefined'))
+            print('to:')
+            print('  %s' % env.get(precious, 'undefined'))
             os.remove(data['cache-file'])
             return True
     return False
@@ -333,8 +333,8 @@
         # We're going to run it ourselves.
         command += ['--no-create']
 
-        print prefix_lines('configuring', relobjdir)
-        print prefix_lines('running %s' % ' '.join(command[:-1]), relobjdir)
+        print(prefix_lines('configuring', relobjdir))
+        print(prefix_lines('running %s' % ' '.join(command[:-1]), relobjdir))
         sys.stdout.flush()
         try:
             output += subprocess.check_output(command,
@@ -368,7 +368,7 @@
 
     if not skip_config_status:
         if skip_configure:
-            print prefix_lines('running config.status', relobjdir)
+            print(prefix_lines('running config.status', relobjdir))
             sys.stdout.flush()
         try:
             output += subprocess.check_output([data['shell'], '-c',
@@ -410,7 +410,7 @@
     pool = Pool(len(subconfigures))
     for relobjdir, returncode, output in \
             pool.imap_unordered(run, subconfigures):
-        print prefix_lines(output, relobjdir)
+        print(prefix_lines(output, relobjdir))
         sys.stdout.flush()
         ret = max(returncode, ret)
         if ret:
--- mozjs-52.4.0/build/moz.configure/old.configure.old	2018-07-10 10:38:53.530000000 +0000
+++ mozjs-52.4.0/build/moz.configure/old.configure	2018-07-10 10:41:32.560000000 +0000
@@ -394,7 +394,7 @@
 def post_old_configure(raw_config):
     for k, v in raw_config['substs']:
         set_old_configure_config(
-            k[1:-1], v[1:-1] if isinstance(v, types.StringTypes) else v)
+            k[1:-1], v[1:-1] if isinstance(v, str) else v)
 
-    for k, v in dict(raw_config['defines']).iteritems():
+    for k, v in dict(raw_config['defines']).items():
         set_old_configure_define(k[1:-1], v[1:-1])
--- mozjs-52.4.0/configure.py	(original)
+++ mozjs-52.4.0/configure.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import print_function, unicode_literals
+
 
 import codecs
 import os
@@ -45,11 +45,11 @@
 
     sanitized_config = {}
     sanitized_config['substs'] = {
-        k: sanitized_bools(v) for k, v in config.iteritems()
+        k: sanitized_bools(v) for k, v in config.items()
         if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR')
     }
     sanitized_config['defines'] = {
-        k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
+        k: sanitized_bools(v) for k, v in config['DEFINES'].items()
     }
     sanitized_config['non_global_defines'] = config['non_global_defines']
     sanitized_config['topsrcdir'] = config['TOPSRCDIR']
@@ -71,7 +71,7 @@
         ''') % {'python': config['PYTHON'], 'encoding': encoding})
         # A lot of the build backend code is currently expecting byte
         # strings and breaks in subtle ways with unicode strings. (bug 1296508)
-        for k, v in sanitized_config.iteritems():
+        for k, v in sanitized_config.items():
             fh.write('%s = encode(%s, encoding)\n' % (k, indented_repr(v)))
         fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', "
                  "'non_global_defines', 'substs', 'mozconfig']")
@@ -88,7 +88,7 @@
     # executable permissions.
     os.chmod('config.status', 0o755)
     if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
-        os.environ[b'WRITE_MOZINFO'] = b'1'
+        os.environ['WRITE_MOZINFO'] = '1'
         from mozbuild.config_status import config_status
 
         # Some values in sanitized_config also have more complex types, such as
--- mozjs-52.4.0/testing/mozbase/mozfile/mozfile/mozfile.py	(original)
+++ mozjs-52.4.0/testing/mozbase/mozfile/mozfile/mozfile.py	(refactored)
@@ -6,7 +6,7 @@
 
 # We don't import all modules at the top for performance reasons. See Bug 1008943
 
-from __future__ import absolute_import
+
 
 from contextlib import contextmanager
 import errno
@@ -55,7 +55,7 @@
         try:
             bundle = zipfile.ZipFile(src)
         except Exception:
-            print "src: %s" % src
+            print("src: %s" % src)
             raise
 
     namelist = bundle.namelist()
@@ -161,8 +161,8 @@
 
             retry_count += 1
 
-            print '%s() failed for "%s". Reason: %s (%s). Retrying...' % \
-                (func.__name__, args, e.strerror, e.errno)
+            print('%s() failed for "%s". Reason: %s (%s). Retrying...' % \
+                (func.__name__, args, e.strerror, e.errno))
             time.sleep(retry_count * retry_delay)
         else:
             # If no exception has been thrown it should be done
@@ -420,9 +420,9 @@
     Return True if thing looks like a URL.
     """
 
-    import urlparse
-
-    parsed = urlparse.urlparse(thing)
+    import urllib.parse
+
+    parsed = urllib.parse.urlparse(thing)
     if 'scheme' in parsed:
         return len(parsed.scheme) >= 2
     else:
@@ -436,7 +436,7 @@
     result of urllib2.urlopen()
     """
 
-    import urllib2
+    import urllib.request, urllib.error, urllib.parse
 
     # handle file URLs separately due to python stdlib limitations
     if resource.startswith('file://'):
@@ -446,4 +446,4 @@
         # if no scheme is given, it is a file path
-        return file(resource)
+        return open(resource)
 
-    return urllib2.urlopen(resource)
+    return urllib.request.urlopen(resource)
--- mozjs-52.4.0/testing/mozbase/mozinfo/mozinfo/mozinfo.py	(original)
+++ mozjs-52.4.0/testing/mozbase/mozinfo/mozinfo/mozinfo.py	(refactored)
@@ -8,7 +8,7 @@
 # linux) to the information; I certainly wouldn't want anyone parsing this
 # information and having behaviour depend on it
 
-from __future__ import absolute_import
+
 
 import os
 import platform
@@ -24,7 +24,7 @@
 class unknown(object):
     """marker class for unknown information"""
 
-    def __nonzero__(self):
+    def __bool__(self):
         return False
 
     def __str__(self):
@@ -184,7 +184,7 @@
                      to a json file containing the new info.
     """
 
-    if isinstance(new_info, basestring):
+    if isinstance(new_info, str):
         # lazy import
         import mozfile
         import json
@@ -246,7 +246,7 @@
 update({})
 
 # exports
-__all__ = info.keys()
+__all__ = list(info.keys())
 __all__ += ['is' + os_name.title() for os_name in choices['os']]
 __all__ += [
     'info',
@@ -284,17 +284,17 @@
 
     # print out choices if requested
     flag = False
-    for key, value in options.__dict__.items():
+    for key, value in list(options.__dict__.items()):
         if value is True:
-            print '%s choices: %s' % (key, ' '.join([str(choice)
-                                                     for choice in choices[key]]))
+            print('%s choices: %s' % (key, ' '.join([str(choice)
+                                                     for choice in choices[key]])))
             flag = True
     if flag:
         return
 
     # otherwise, print out all info
-    for key, value in info.items():
-        print '%s: %s' % (key, value)
+    for key, value in list(info.items()):
+        print('%s: %s' % (key, value))
 
 if __name__ == '__main__':
     main()
--- mozjs-52.4.0/testing/mozbase/mozinfo/mozinfo/string_version.py.old	2017-04-11 02:13:06.000000000 +0000
+++ mozjs-52.4.0/testing/mozbase/mozinfo/mozinfo/string_version.py	2018-07-10 11:10:56.140000000 +0000
@@ -10,8 +10,10 @@
     A string version that can be compared with comparison operators.
     """
 
+    def __new__(cls, value):
+        return str.__new__(cls, value)
+
     def __init__(self, vstring):
-        str.__init__(self, vstring)
         self.version = LooseVersion(vstring)
 
     def __repr__(self):
--- mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/manifestparser.py	(original)
+++ mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/manifestparser.py	(refactored)
@@ -2,7 +2,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from StringIO import StringIO
+from io import StringIO
 import json
 import fnmatch
 import os
@@ -21,7 +21,7 @@
 __all__ = ['ManifestParser', 'TestManifest', 'convert']
 
 relpath = os.path.relpath
-string = (basestring,)
+string = (str,)
 
 
 # path normalization
@@ -178,7 +178,7 @@
 
             # otherwise an item
             # apply ancestor defaults, while maintaining current file priority
-            data = dict(self._ancestor_defaults.items() + data.items())
+            data = dict(list(self._ancestor_defaults.items()) + list(data.items()))
 
             test = data
             test['name'] = section
@@ -306,19 +306,19 @@
         # make some check functions
         if inverse:
             def has_tags(test):
-                return not tags.intersection(test.keys())
+                return not tags.intersection(list(test.keys()))
 
             def dict_query(test):
-                for key, value in kwargs.items():
+                for key, value in list(kwargs.items()):
                     if test.get(key) == value:
                         return False
                 return True
         else:
             def has_tags(test):
-                return tags.issubset(test.keys())
+                return tags.issubset(list(test.keys()))
 
             def dict_query(test):
-                for key, value in kwargs.items():
+                for key, value in list(kwargs.items()):
                     if test.get(key) != value:
                         return False
                 return True
@@ -340,7 +340,7 @@
         """
         if tests is None:
             # Make sure to return all the manifests, even ones without tests.
-            return self.manifest_defaults.keys()
+            return list(self.manifest_defaults.keys())
 
         manifests = []
         for test in tests:
@@ -373,8 +373,8 @@
                 raise IOError("Strict mode enabled, test paths must exist. "
                               "The following test(s) are missing: %s" %
                               json.dumps(missing_paths, indent=2))
-            print >> sys.stderr, "Warning: The following test(s) are missing: %s" % \
-                json.dumps(missing_paths, indent=2)
+            print("Warning: The following test(s) are missing: %s" % \
+                json.dumps(missing_paths, indent=2), file=sys.stderr)
         return missing
 
     def verifyDirectory(self, directories, pattern=None, extensions=None):
@@ -385,7 +385,7 @@
         """
 
         files = set([])
-        if isinstance(directories, basestring):
+        if isinstance(directories, str):
             directories = [directories]
 
         # get files in directories
@@ -449,12 +449,12 @@
 
         # print the .ini manifest
         if global_tags or global_kwargs:
-            print >> fp, '[DEFAULT]'
+            print('[DEFAULT]', file=fp)
             for tag in global_tags:
-                print >> fp, '%s =' % tag
-            for key, value in global_kwargs.items():
-                print >> fp, '%s = %s' % (key, value)
-            print >> fp
+                print('%s =' % tag, file=fp)
+            for key, value in list(global_kwargs.items()):
+                print('%s = %s' % (key, value), file=fp)
+            print(file=fp)
 
         for test in tests:
             test = test.copy()  # don't overwrite
@@ -465,7 +465,7 @@
                 if self.rootdir:
                     path = relpath(test['path'], self.rootdir)
                 path = denormalize_path(path)
-            print >> fp, '[%s]' % path
+            print('[%s]' % path, file=fp)
 
             # reserved keywords:
             reserved = ['path', 'name', 'here', 'manifest', 'relpath', 'ancestor-manifest']
@@ -476,8 +476,8 @@
                     continue
                 if key in global_tags and not test[key]:
                     continue
-                print >> fp, '%s = %s' % (key, test[key])
-            print >> fp
+                print('%s = %s' % (key, test[key]), file=fp)
+            print(file=fp)
 
         if close:
             # close the created file
@@ -565,7 +565,7 @@
                     message = "Missing test: '%s' does not exist!"
                     if self.strict:
                         raise IOError(message)
-                    print >> sys.stderr, message + " Skipping."
+                    print(message + " Skipping.", file=sys.stderr)
                     continue
                 destination = os.path.join(rootdir, _relpath)
                 shutil.copy(source, destination)
@@ -578,7 +578,7 @@
         internal function to import directories
         """
 
-        if isinstance(pattern, basestring):
+        if isinstance(pattern, str):
             patterns = [pattern]
         else:
             patterns = pattern
@@ -670,9 +670,9 @@
             if (dirnames or filenames) and not (os.path.exists(manifest_path) and overwrite):
                 with file(manifest_path, 'w') as manifest:
                     for dirname in dirnames:
-                        print >> manifest, '[include:%s]' % os.path.join(dirname, filename)
+                        print('[include:%s]' % os.path.join(dirname, filename), file=manifest)
                     for _filename in filenames:
-                        print >> manifest, '[%s]' % _filename
+                        print('[%s]' % _filename, file=manifest)
 
                 # add to list of manifests
                 manifest_dict.setdefault(directory, manifest_path)
@@ -722,8 +722,8 @@
                              for filename in filenames]
 
             # write to manifest
-            print >> write, '\n'.join(['[%s]' % denormalize_path(filename)
-                                       for filename in filenames])
+            print('\n'.join(['[%s]' % denormalize_path(filename)
+                                       for filename in filenames]), file=write)
 
         cls._walk_directories(directories, callback, pattern=pattern, ignore=ignore)
 
--- mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/expression.py	(original)
+++ mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/expression.py	(refactored)
@@ -275,7 +275,7 @@
         """
         if not isinstance(self.token, expected):
             raise Exception("Unexpected token!")
-        self.token = self.iter.next()
+        self.token = next(self.iter)
 
     def expression(self, rbp=0):
         """
@@ -283,11 +283,11 @@
         right binding power greater than rbp is encountered.
         """
         t = self.token
-        self.token = self.iter.next()
+        self.token = next(self.iter)
         left = t.nud(self)
         while rbp < self.token.lbp:
             t = self.token
-            self.token = self.iter.next()
+            self.token = next(self.iter)
             left = t.led(self, left)
         return left
 
@@ -299,7 +299,7 @@
         """
         try:
             self.iter = self._tokenize()
-            self.token = self.iter.next()
+            self.token = next(self.iter)
             return self.expression()
         except:
             extype, ex, tb = sys.exc_info()
@@ -307,7 +307,7 @@
             raise ParseError("could not parse: "
                              "%s\nexception: %svariables: %s" % (self.text,
                                                                  formatted,
-                                                                 self.valuemapping)), None, tb
+                                                                 self.valuemapping)).with_traceback(tb)
 
     __call__ = parse
 
--- mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/filters.py	(original)
+++ mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/filters.py	(refactored)
@@ -92,7 +92,7 @@
     def __init__(self, *args, **kwargs):
         self.fmt_args = ', '.join(itertools.chain(
             [str(a) for a in args],
-            ['{}={}'.format(k, v) for k, v in kwargs.iteritems()]))
+            ['{}={}'.format(k, v) for k, v in kwargs.items()]))
 
     def __eq__(self, other):
         if self.unique:
@@ -249,7 +249,7 @@
         # be yielded for reporting purposes. Put them all in chunk 1 for
         # simplicity.
         if self.this_chunk == 1:
-            disabled_dirs = [v for k, v in tests_by_dir.iteritems()
+            disabled_dirs = [v for k, v in tests_by_dir.items()
                              if k not in ordered_dirs]
             for disabled_test in itertools.chain(*disabled_dirs):
                 yield disabled_test
@@ -326,7 +326,7 @@
 
     def __init__(self, tags):
         InstanceFilter.__init__(self, tags)
-        if isinstance(tags, basestring):
+        if isinstance(tags, str):
             tags = [tags]
         self.tags = tags
 
@@ -349,7 +349,7 @@
 
     def __init__(self, paths):
         InstanceFilter.__init__(self, paths)
-        if isinstance(paths, basestring):
+        if isinstance(paths, str):
             paths = [paths]
         self.paths = paths
 
--- mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/ini.py	(original)
+++ mozjs-52.4.0/testing/mozbase/manifestparser/manifestparser/ini.py	(refactored)
@@ -27,7 +27,7 @@
     sections = []
     key = value = None
     section_names = set()
-    if isinstance(fp, basestring):
-        fp = file(fp)
+    if isinstance(fp, str):
+        fp = open(fp)
 
     # read the lines
@@ -131,7 +131,7 @@
         'support-files': '%s %s',
     }
     final_mapping = global_vars.copy()
-    for field_name, value in local_vars.items():
+    for field_name, value in list(local_vars.items()):
         if field_name not in field_patterns or field_name not in global_vars:
             final_mapping[field_name] = value
             continue
--- mozjs-52.4.0/python/mozbuild/mozbuild/util.py.old	2018-07-10 11:16:10.690000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/util.py	2018-07-10 23:36:02.250000000 +0000
@@ -1254,10 +1254,10 @@
             encode(k, encoding): encode(v, encoding)
             for k, v in obj.items()
         }
-    if isinstance(obj, bytes):
-        return obj
     if isinstance(obj, str):
-        return obj.encode(encoding)
+        return obj
+    if isinstance(obj, bytes):
+        return obj.decode(encoding)
     if isinstance(obj, Iterable):
         return [encode(i, encoding) for i in obj]
     return obj
--- mozjs-52.4.0/python/mozbuild/mozbuild/util.py.old	2018-07-10 23:36:33.980000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/util.py	2018-07-10 23:41:51.900000000 +0000
@@ -1179,6 +1179,9 @@
             POSSIBLE_VALUES = possible_values
         return EnumStringSubclass
 
+    def __hash__(self):
+        return hash(str(self))
+
 
 def _escape_char(c):
     # str.encode('unicode_espace') doesn't escape quotes, presumably because
--- mozjs-52.4.0/python/mozbuild/mozbuild/mozinfo.py.old	2018-07-10 23:42:19.390000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/mozinfo.py	2018-07-11 01:45:57.930000000 +0000
@@ -155,6 +155,6 @@
     """
     build_conf = build_dict(config, env)
     if isinstance(file, str):
-        file = open(file, 'wb')
+        file = open(file, 'w')
 
     json.dump(build_conf, file, sort_keys=True, indent=4)
--- mozjs-52.4.0/python/mozbuild/mozbuild/jar.py.old	2018-07-11 01:46:26.540000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/jar.py	2018-07-11 02:02:36.010000000 +0000
@@ -16,7 +16,7 @@
 import re
 import logging
 from time import localtime
-from MozZipFile import ZipFile
+from zipfile import ZipFile
 from io import StringIO
 from collections import defaultdict
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/util.py.old	2018-07-11 02:05:38.530000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/util.py	2018-07-11 02:08:21.020000000 +0000
@@ -987,8 +987,6 @@
                                     'got %s, expected %s' % (fname,
                                     type(value), ftype))
 
-            super(TypedTuple, self).__init__(*args, **kwargs)
-
     TypedTuple._fields = fields
 
     return TypedTuple
--- mozjs-52.4.0/build/moz.configure/init.configure.old	2018-07-11 02:08:50.000000000 +0000
+++ mozjs-52.4.0/build/moz.configure/init.configure	2018-07-11 04:04:26.600000000 +0000
@@ -297,7 +297,9 @@
     # There is also a quartet form:
     #   CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
     # But we can consider the "KERNEL-OPERATING_SYSTEM" as one.
-    cpu, manufacturer, os = triplet.decode('utf-8').split('-', 2)
+    if isinstance(triplet, bytes):
+        triplet = triplet.decode('utf-8')
+    cpu, manufacturer, os = triplet.split('-', 2)
 
     # Autoconf uses config.sub to validate and canonicalize those triplets,
     # but the granularity of its results has never been satisfying to our
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py.old	2018-07-11 04:25:33.980000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py	2018-07-11 04:24:50.630000000 +0000
@@ -441,6 +441,8 @@
         code = func.__code__
         firstlineno = code.co_firstlineno
         lines = sandbox._current_source.splitlines(True)
+        if len(lines) and isinstance(lines[0], bytes):
+            lines = [l.decode('utf-8') for l in lines]
         lines = inspect.getblock(lines[firstlineno - 1:])
 
         # The code lines we get out of inspect.getsourcelines look like
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py.old	2018-07-11 04:25:57.090000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/reader.py	2018-07-11 04:29:46.140000000 +0000
@@ -460,7 +460,7 @@
         # actually never calls __getitem__ and __setitem__, so we need to
         # modify the AST so that accesses to globals are properly directed
         # to a dict.
-        self._global_name = b'_data' # AST wants str for this, not unicode
+        self._global_name = '_data' # AST wants str for this, not unicode
         # In case '_data' is a name used for a variable in the function code,
         # prepend more underscores until we find an unused name.
         while (self._global_name in code.co_names or
--- mozjs-52.4.0/python/mozbuild/mozbuild/frontend/context.py.old	2018-07-11 04:30:06.590000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/frontend/context.py	2018-07-11 04:35:38.670000000 +0000
@@ -384,8 +384,8 @@
 
     def __cmp__(self, other):
         if isinstance(other, Path) and self.srcdir != other.srcdir:
-            return cmp(self.full_path, other.full_path)
-        return cmp(str(self), other)
+            return self.full_path == other.full_path
+        return str(self) == other
 
     # __cmp__ is not enough because unicode has __eq__, __ne__, etc. defined
     # and __cmp__ is only used for those when they don't exist.
--- mozjs-52.4.0/mozglue/build/moz.build.old	2018-07-11 04:40:17.930000000 +0000
+++ mozjs-52.4.0/mozglue/build/moz.build	2018-07-11 04:42:00.830000000 +0000
@@ -4,20 +4,15 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-# Build mozglue as a shared lib on Windows, OSX and Android.
+# Build mozglue as a shared lib on Windows and OSX.
 # If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in
-if CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android') and not CONFIG['JS_STANDALONE']:
+if CONFIG['OS_TARGET'] in ('WINNT', 'Darwin') and not CONFIG['JS_STANDALONE']:
     SharedLibrary('mozglue')
 else:
     Library('mozglue')
 
 SDK_LIBRARY = True
 
-if CONFIG['OS_TARGET'] == 'Android':
-    SOURCES += [
-        'BionicGlue.cpp',
-    ]
-
 if CONFIG['MOZ_ASAN']:
     SOURCES += [
         'AsanOptions.cpp',
--- mozjs-52.4.0/js/src/moz.build.old	2017-04-11 02:13:16.000000000 +0000
+++ mozjs-52.4.0/js/src/moz.build	2018-07-11 04:43:59.920000000 +0000
@@ -707,7 +707,7 @@
     CXXFLAGS += ['-wd4577']
     CXXFLAGS += ['-wd4312']
 
-if CONFIG['OS_ARCH'] not in ('WINNT', 'HP-UX'):
+if CONFIG['OS_ARCH'] != 'WINNT':
     OS_LIBS += [
         'm',
     ]
@@ -722,13 +722,13 @@
         'dl',
     ]
 
-if CONFIG['OS_ARCH'] == 'SunOS':
-    OS_LIBS += [
-        'posix4',
-        'dl',
-        'nsl',
-        'socket',
-    ]
+#if CONFIG['OS_ARCH'] == 'SunOS':
+#    OS_LIBS += [
+#        'posix4',
+#        'dl',
+#        'nsl',
+#        'socket',
+#    ]
 
 OS_LIBS += CONFIG['REALTIME_LIBS']
 
--- mozjs-52.4.0/python/mozbuild/mozbuild/util.py.old	2018-07-11 04:44:24.900000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/util.py	2018-07-11 04:46:47.310000000 +0000
@@ -267,6 +267,10 @@
             if 'b' in self.mode:
                 writemode += 'b'
             with open(self.name, writemode) as file:
+                if 'b' in self.mode and isinstance(buf, str):
+                    buf = buf.encode('utf-8')
+                elif 'b' not in self.mode and isinstance(buf, bytes):
+                    buf = buf.decode('utf-8')
                 file.write(buf)
 
         if self._capture_diff:
--- mozjs-52.4.0/python/mozbuild/mozbuild/backend/recursivemake.py.old	2018-07-11 04:47:15.020000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/backend/recursivemake.py	2018-07-11 04:53:51.750000000 +0000
@@ -77,86 +77,86 @@
 from functools import reduce
 
 MOZBUILD_VARIABLES = [
-    b'ANDROID_APK_NAME',
-    b'ANDROID_APK_PACKAGE',
-    b'ANDROID_ASSETS_DIRS',
-    b'ANDROID_EXTRA_PACKAGES',
-    b'ANDROID_EXTRA_RES_DIRS',
-    b'ANDROID_GENERATED_RESFILES',
-    b'ANDROID_RES_DIRS',
-    b'ASFLAGS',
-    b'CMSRCS',
-    b'CMMSRCS',
-    b'CPP_UNIT_TESTS',
-    b'DIRS',
-    b'DIST_INSTALL',
-    b'EXTRA_DSO_LDOPTS',
-    b'EXTRA_JS_MODULES',
-    b'EXTRA_PP_COMPONENTS',
-    b'EXTRA_PP_JS_MODULES',
-    b'FORCE_SHARED_LIB',
-    b'FORCE_STATIC_LIB',
-    b'FINAL_LIBRARY',
-    b'HOST_CFLAGS',
-    b'HOST_CSRCS',
-    b'HOST_CMMSRCS',
-    b'HOST_CXXFLAGS',
-    b'HOST_EXTRA_LIBS',
-    b'HOST_LIBRARY_NAME',
-    b'HOST_PROGRAM',
-    b'HOST_SIMPLE_PROGRAMS',
-    b'IS_COMPONENT',
-    b'JAR_MANIFEST',
-    b'JAVA_JAR_TARGETS',
-    b'LD_VERSION_SCRIPT',
-    b'LIBRARY_NAME',
-    b'LIBS',
-    b'MAKE_FRAMEWORK',
-    b'MODULE',
-    b'NO_DIST_INSTALL',
-    b'NO_EXPAND_LIBS',
-    b'NO_INTERFACES_MANIFEST',
-    b'NO_JS_MANIFEST',
-    b'OS_LIBS',
-    b'PARALLEL_DIRS',
-    b'PREF_JS_EXPORTS',
-    b'PROGRAM',
-    b'PYTHON_UNIT_TESTS',
-    b'RESOURCE_FILES',
-    b'SDK_HEADERS',
-    b'SDK_LIBRARY',
-    b'SHARED_LIBRARY_LIBS',
-    b'SHARED_LIBRARY_NAME',
-    b'SIMPLE_PROGRAMS',
-    b'SONAME',
-    b'STATIC_LIBRARY_NAME',
-    b'TEST_DIRS',
-    b'TOOL_DIRS',
+    'ANDROID_APK_NAME',
+    'ANDROID_APK_PACKAGE',
+    'ANDROID_ASSETS_DIRS',
+    'ANDROID_EXTRA_PACKAGES',
+    'ANDROID_EXTRA_RES_DIRS',
+    'ANDROID_GENERATED_RESFILES',
+    'ANDROID_RES_DIRS',
+    'ASFLAGS',
+    'CMSRCS',
+    'CMMSRCS',
+    'CPP_UNIT_TESTS',
+    'DIRS',
+    'DIST_INSTALL',
+    'EXTRA_DSO_LDOPTS',
+    'EXTRA_JS_MODULES',
+    'EXTRA_PP_COMPONENTS',
+    'EXTRA_PP_JS_MODULES',
+    'FORCE_SHARED_LIB',
+    'FORCE_STATIC_LIB',
+    'FINAL_LIBRARY',
+    'HOST_CFLAGS',
+    'HOST_CSRCS',
+    'HOST_CMMSRCS',
+    'HOST_CXXFLAGS',
+    'HOST_EXTRA_LIBS',
+    'HOST_LIBRARY_NAME',
+    'HOST_PROGRAM',
+    'HOST_SIMPLE_PROGRAMS',
+    'IS_COMPONENT',
+    'JAR_MANIFEST',
+    'JAVA_JAR_TARGETS',
+    'LD_VERSION_SCRIPT',
+    'LIBRARY_NAME',
+    'LIBS',
+    'MAKE_FRAMEWORK',
+    'MODULE',
+    'NO_DIST_INSTALL',
+    'NO_EXPAND_LIBS',
+    'NO_INTERFACES_MANIFEST',
+    'NO_JS_MANIFEST',
+    'OS_LIBS',
+    'PARALLEL_DIRS',
+    'PREF_JS_EXPORTS',
+    'PROGRAM',
+    'PYTHON_UNIT_TESTS',
+    'RESOURCE_FILES',
+    'SDK_HEADERS',
+    'SDK_LIBRARY',
+    'SHARED_LIBRARY_LIBS',
+    'SHARED_LIBRARY_NAME',
+    'SIMPLE_PROGRAMS',
+    'SONAME',
+    'STATIC_LIBRARY_NAME',
+    'TEST_DIRS',
+    'TOOL_DIRS',
     # XXX config/Makefile.in specifies this in a make invocation
     #'USE_EXTENSION_MANIFEST',
-    b'XPCSHELL_TESTS',
-    b'XPIDL_MODULE',
+    'XPCSHELL_TESTS',
+    'XPIDL_MODULE',
 ]
 
 DEPRECATED_VARIABLES = [
-    b'ANDROID_RESFILES',
-    b'EXPORT_LIBRARY',
-    b'EXTRA_LIBS',
-    b'HOST_LIBS',
-    b'LIBXUL_LIBRARY',
-    b'MOCHITEST_A11Y_FILES',
-    b'MOCHITEST_BROWSER_FILES',
-    b'MOCHITEST_BROWSER_FILES_PARTS',
-    b'MOCHITEST_CHROME_FILES',
-    b'MOCHITEST_FILES',
-    b'MOCHITEST_FILES_PARTS',
-    b'MOCHITEST_METRO_FILES',
-    b'MOCHITEST_ROBOCOP_FILES',
-    b'MODULE_OPTIMIZE_FLAGS',
-    b'MOZ_CHROME_FILE_FORMAT',
-    b'SHORT_LIBNAME',
-    b'TESTING_JS_MODULES',
-    b'TESTING_JS_MODULE_DIR',
+    'ANDROID_RESFILES',
+    'EXPORT_LIBRARY',
+    'EXTRA_LIBS',
+    'HOST_LIBS',
+    'LIBXUL_LIBRARY',
+    'MOCHITEST_A11Y_FILES',
+    'MOCHITEST_BROWSER_FILES',
+    'MOCHITEST_BROWSER_FILES_PARTS',
+    'MOCHITEST_CHROME_FILES',
+    'MOCHITEST_FILES',
+    'MOCHITEST_FILES_PARTS',
+    'MOCHITEST_METRO_FILES',
+    'MOCHITEST_ROBOCOP_FILES',
+    'MODULE_OPTIMIZE_FLAGS',
+    'MOZ_CHROME_FILE_FORMAT',
+    'SHORT_LIBNAME',
+    'TESTING_JS_MODULES',
+    'TESTING_JS_MODULE_DIR',
 ]
 
 MOZBUILD_VARIABLES_MESSAGE = 'It should only be defined in moz.build files.'
@@ -758,7 +758,7 @@
             rule.add_dependencies(['$(CURDIR)/%: %'])
 
     def _check_blacklisted_variables(self, makefile_in, makefile_content):
-        if b'EXTERNALLY_MANAGED_MAKE_FILE' in makefile_content:
+        if 'EXTERNALLY_MANAGED_MAKE_FILE' in makefile_content:
             # Bypass the variable restrictions for externally managed makefiles.
             return
 
@@ -765,7 +765,7 @@
         for l in makefile_content.splitlines():
             l = l.strip()
             # Don't check comments
-            if l.startswith(b'#'):
+            if l.startswith('#'):
                 continue
             for x in chain(MOZBUILD_VARIABLES, DEPRECATED_VARIABLES):
                 if x not in l:
@@ -822,11 +822,11 @@
                     # Skip every directory but those with a Makefile
                     # containing a tools target, or XPI_PKGNAME or
                     # INSTALL_EXTENSION_ID.
-                    for t in (b'XPI_PKGNAME', b'INSTALL_EXTENSION_ID',
-                            b'tools'):
+                    for t in ('XPI_PKGNAME', 'INSTALL_EXTENSION_ID',
+                            'tools'):
                         if t not in content:
                             continue
-                        if t == b'tools' and not re.search('(?:^|\s)tools.*::', content, re.M):
+                        if t == 'tools' and not re.search('(?:^|\s)tools.*::', content, re.M):
                             continue
                         if objdir == self.environment.topobjdir:
                             continue
@@ -1422,20 +1422,20 @@
                 pp.context.update(extra)
             if not pp.context.get('autoconfmk', ''):
                 pp.context['autoconfmk'] = 'autoconf.mk'
-            pp.handleLine(b'# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
-            pp.handleLine(b'DEPTH := @DEPTH@\n')
-            pp.handleLine(b'topobjdir := @topobjdir@\n')
-            pp.handleLine(b'topsrcdir := @top_srcdir@\n')
-            pp.handleLine(b'srcdir := @srcdir@\n')
-            pp.handleLine(b'VPATH := @srcdir@\n')
-            pp.handleLine(b'relativesrcdir := @relativesrcdir@\n')
-            pp.handleLine(b'include $(DEPTH)/config/@autoconfmk@\n')
+            pp.handleLine('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
+            pp.handleLine('DEPTH := @DEPTH@\n')
+            pp.handleLine('topobjdir := @topobjdir@\n')
+            pp.handleLine('topsrcdir := @top_srcdir@\n')
+            pp.handleLine('srcdir := @srcdir@\n')
+            pp.handleLine('VPATH := @srcdir@\n')
+            pp.handleLine('relativesrcdir := @relativesrcdir@\n')
+            pp.handleLine('include $(DEPTH)/config/@autoconfmk@\n')
             if not stub:
                 pp.do_include(obj.input_path)
             # Empty line to avoid failures when last line in Makefile.in ends
             # with a backslash.
-            pp.handleLine(b'\n')
-            pp.handleLine(b'include $(topsrcdir)/config/recurse.mk\n')
+            pp.handleLine('\n')
+            pp.handleLine('include $(topsrcdir)/config/recurse.mk\n')
         if not stub:
             # Adding the Makefile.in here has the desired side-effect
             # that if the Makefile.in disappears, this will force
--- mozjs-52.4.0/python/mozbuild/mozpack/manifests.py.old	2018-07-11 04:54:39.260000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozpack/manifests.py	2018-07-11 04:57:31.710000000 +0000
@@ -115,7 +115,7 @@
         self._source_files = set()
 
         if path or fileobj:
-            with _auto_fileobj(path, fileobj, 'rb') as fh:
+            with _auto_fileobj(path, fileobj, 'r') as fh:
                 self._source_files.add(fh.name)
                 self._load_from_fileobj(fh)
 
@@ -174,7 +174,7 @@
                 dest, content = fields[1:]
 
                 self.add_content(
-                    self._decode_field_entry(content).encode('utf-8'), dest)
+                    self._decode_field_entry(content), dest)
                 continue
 
             # Don't fail for non-actionable items, allowing
@@ -236,7 +236,7 @@
 
         It is an error if both are specified.
         """
-        with _auto_fileobj(path, fileobj, 'wb') as fh:
+        with _auto_fileobj(path, fileobj, 'w') as fh:
             fh.write('%d\n' % self.CURRENT_VERSION)
 
             for dest in sorted(self._dests):
@@ -244,8 +244,7 @@
 
                 parts = ['%d' % entry[0], dest]
                 parts.extend(entry[1:])
-                fh.write('%s\n' % self.FIELD_SEPARATOR.join(
-                    p.encode('utf-8') for p in parts))
+                fh.write('%s\n' % self.FIELD_SEPARATOR.join(parts))
 
     def add_symlink(self, source, dest):
         """Add a symlink to this manifest.
@@ -391,7 +390,7 @@
             if install_type == self.CONTENT:
                 # GeneratedFile expect the buffer interface, which the unicode
                 # type doesn't have, so encode to a str.
-                content = self._decode_field_entry(entry[1]).encode('utf-8')
+                content = self._decode_field_entry(entry[1])
                 registry.add(dest, GeneratedFile(content))
                 continue
 
--- mozjs-52.4.0/config/MozZipFile.py	(original)
+++ mozjs-52.4.0/config/MozZipFile.py	(refactored)
@@ -18,7 +18,7 @@
   def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED,
                lock = False):
     if lock:
-      assert isinstance(file, basestring)
+      assert isinstance(file, str)
       self.lockfile = lock_file(file + '.lck')
     else:
       self.lockfile = None
@@ -46,7 +46,7 @@
                               date_time=time.localtime(time.time()))
       zinfo.compress_type = self.compression
       # Add some standard UNIX file access permissions (-rw-r--r--).
-      zinfo.external_attr = (0x81a4 & 0xFFFF) << 16L
+      zinfo.external_attr = (0x81a4 & 0xFFFF) << 16
     else:
       zinfo = zinfo_or_arcname
 
@@ -58,7 +58,7 @@
     # as the old, reuse the existing entry.
 
     doSeek = False # store if we need to seek to the eof after overwriting
-    if self.NameToInfo.has_key(zinfo.filename):
+    if zinfo.filename in self.NameToInfo:
       # Find the last ZipInfo with our name.
       # Last, because that's catching multiple overwrites
       i = len(self.filelist)
@@ -109,14 +109,14 @@
       # adjust file mode if we originally just wrote, now we rewrite
       self.fp.close()
       self.fp = open(self.filename, 'r+b')
-    all = map(lambda zi: (zi, True), self.filelist) + \
-        map(lambda zi: (zi, False), self._remove)
+    all = [(zi, True) for zi in self.filelist] + \
+        [(zi, False) for zi in self._remove]
     all.sort(lambda l, r: cmp(l[0].header_offset, r[0].header_offset))
     # empty _remove for multiple closes
     self._remove = []
 
     lengths = [all[i+1][0].header_offset - all[i][0].header_offset
-               for i in xrange(len(all)-1)]
+               for i in range(len(all)-1)]
     lengths.append(self.end - all[-1][0].header_offset)
     to_pos = 0
     for (zi, keep), length in zip(all, lengths):
--- mozjs-52.4.0/config/check_spidermonkey_style.py	(original)
+++ mozjs-52.4.0/config/check_spidermonkey_style.py	(refactored)
@@ -35,7 +35,7 @@
 #   isolation, but don't try to do any order checking between such blocks.
 #----------------------------------------------------------------------------
 
-from __future__ import print_function
+
 
 import difflib
 import os
@@ -270,7 +270,7 @@
         edges[inclname] = set()
 
     # Process all the JS files.
-    for filename in js_names.keys():
+    for filename in list(js_names.keys()):
         inclname = js_names[filename]
         file_kind = FileKind.get(filename)
         if file_kind == FileKind.C or file_kind == FileKind.CPP or \
--- mozjs-52.4.0/config/expandlibs.py	(original)
+++ mozjs-52.4.0/config/expandlibs.py	(refactored)
@@ -26,7 +26,7 @@
   descriptor contains. And for each of these LIBS, also apply the same
   rules.
 '''
-from __future__ import with_statement
+
 import sys, os, errno
 import expandlibs_config as conf
 
@@ -36,7 +36,7 @@
     if dir and not os.path.exists(dir):
         try:
             os.makedirs(dir)
-        except OSError, error:
+        except OSError as error:
             if error.errno != errno.EEXIST:
                 raise
 
@@ -140,4 +140,4 @@
         return [relativize(arg)]
 
 if __name__ == '__main__':
-    print " ".join(ExpandArgs(sys.argv[1:]))
+    print(" ".join(ExpandArgs(sys.argv[1:])))
--- mozjs-52.4.0/config/expandlibs_exec.py	(original)
+++ mozjs-52.4.0/config/expandlibs_exec.py	(refactored)
@@ -20,7 +20,7 @@
 relevant linker options to change the order in which the linker puts the
 symbols appear in the resulting binary. Only works for ELF targets.
 '''
-from __future__ import with_statement
+
 import sys
 import os
 from expandlibs import (
@@ -304,11 +304,11 @@
         return syms
 
 def print_command(out, args):
-    print >>out, "Executing: " + " ".join(args)
+    print("Executing: " + " ".join(args), file=out)
     for tmp in [f for f in args.tmp if os.path.isfile(f)]:
-        print >>out, tmp + ":"
+        print(tmp + ":", file=out)
         with open(tmp) as file:
-            print >>out, "".join(["    " + l for l in file.readlines()])
+            print("".join(["    " + l for l in file.readlines()]), file=out)
     out.flush()
 
 def main(args, proc_callback=None):
@@ -338,8 +338,8 @@
             proc = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
             if proc_callback:
                 proc_callback(proc)
-        except Exception, e:
-            print >>sys.stderr, 'error: Launching', args, ':', e
+        except Exception as e:
+            print('error: Launching', args, ':', e, file=sys.stderr)
             raise e
         (stdout, stderr) = proc.communicate()
         if proc.returncode and not options.verbose:
--- mozjs-52.4.0/config/expandlibs_gen.py	(original)
+++ mozjs-52.4.0/config/expandlibs_gen.py	(refactored)
@@ -5,7 +5,7 @@
 '''Given a list of object files and library names, prints a library
 descriptor to standard output'''
 
-from __future__ import with_statement
+
 import sys
 import os
 import expandlibs_config as conf
@@ -38,4 +38,4 @@
 
     ensureParentDir(options.output)
     with open(options.output, 'w') as outfile:
-        print >>outfile, generate(args)
+        print(generate(args), file=outfile)
--- mozjs-52.4.0/config/find_OOM_errors.py	(original)
+++ mozjs-52.4.0/config/find_OOM_errors.py	(refactored)
@@ -2,7 +2,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from __future__ import print_function
+
 
 usage = """%prog: A test for OOM conditions in the shell.
 
@@ -95,12 +95,12 @@
   """Keep track of the amount of times individual lines occur, in order to
      prioritize the errors which occur most frequently."""
   counts = {}
-  for string,count in blacklist.items():
+  for string,count in list(blacklist.items()):
     for line in string.split("\n"):
       counts[line] = counts.get(line, 0) + count
 
   lines = []
-  for k,v in counts.items():
+  for k,v in list(counts.items()):
     lines.append("{0:6}: {1}".format(v, k))
 
   lines.sort()
--- mozjs-52.4.0/config/nsinstall.py	(original)
+++ mozjs-52.4.0/config/nsinstall.py	(refactored)
@@ -9,7 +9,7 @@
 # a full build environment set up.
 # The basic limitation is, it doesn't even try to link and ignores
 # all related options.
-from __future__ import print_function
+
 from optparse import OptionParser
 import mozfile
 import os
@@ -149,7 +149,7 @@
 
 # nsinstall as a native command is always UTF-8
 def nsinstall(argv):
-  return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv])
+  return _nsinstall_internal([str(arg, "utf-8") for arg in argv])
 
 if __name__ == '__main__':
   # sys.argv corrupts characters outside the system code page on Windows
@@ -175,8 +175,8 @@
   else:
     # For consistency, do it on Unix as well
     if sys.stdin.encoding is not None:
-      argv = [unicode(arg, sys.stdin.encoding) for arg in sys.argv]
+      argv = [str(arg, sys.stdin.encoding) for arg in sys.argv]
     else:
-      argv = [unicode(arg) for arg in sys.argv]
+      argv = [str(arg) for arg in sys.argv]
 
   sys.exit(_nsinstall_internal(argv[1:]))
--- mozjs-52.4.0/config/printconfigsetting.py	(original)
+++ mozjs-52.4.0/config/printconfigsetting.py	(refactored)
@@ -5,12 +5,12 @@
 import configobj
 import sys
 import re
-from StringIO import StringIO
+from io import StringIO
 
 try:
     (file, section, key) = sys.argv[1:]
 except ValueError:
-    print "Usage: printconfigsetting.py <file> <section> <setting>"
+    print("Usage: printconfigsetting.py <file> <section> <setting>")
     sys.exit(1)
 
 with open(file) as fh:
@@ -21,11 +21,11 @@
 try:
     s = c[section]
 except KeyError:
-    print >>sys.stderr, "Section [%s] not found." % section
+    print("Section [%s] not found." % section, file=sys.stderr)
     sys.exit(1)
 
 try:
-    print s[key]
+    print(s[key])
 except KeyError:
-    print >>sys.stderr, "Key %s not found." % key
+    print("Key %s not found." % key, file=sys.stderr)
     sys.exit(1)
--- mozjs-52.4.0/config/pythonpath.py	(original)
+++ mozjs-52.4.0/config/pythonpath.py	(refactored)
@@ -9,7 +9,7 @@
 
 def main(args):
     def usage():
-        print >>sys.stderr, "pythonpath.py -I directory script.py [args...]"
+        print("pythonpath.py -I directory script.py [args...]", file=sys.stderr)
         sys.exit(150)
 
     paths = []
@@ -45,7 +45,7 @@
     frozenglobals['__name__'] = '__main__'
     frozenglobals['__file__'] = script
 
-    execfile(script, frozenglobals)
+    exec(compile(open(script).read(), script, 'exec'), frozenglobals)
 
 # Freeze scope here ... why this makes things work I have no idea ...
 frozenglobals = globals()
--- mozjs-52.4.0/config/rebuild_check.py	(original)
+++ mozjs-52.4.0/config/rebuild_check.py	(refactored)
@@ -18,7 +18,7 @@
     deps = args[1:]
     t = mtime(target)
     if t < 0:
-        print target
+        print(target)
         return
 
     newer = []
@@ -31,13 +31,13 @@
             newer.append(dep)
 
     if newer and removed:
-        print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
+        print('Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed)))
     elif newer:
-        print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
+        print('Rebuilding %s because %s changed' % (target, ', '.join(newer)))
     elif removed:
-        print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
+        print('Rebuilding %s because %s was removed' % (target, ', '.join(removed)))
     else:
-        print 'Rebuilding %s for an unknown reason' % target
+        print('Rebuilding %s for an unknown reason' % target)
 
 if __name__ == '__main__':
     import sys
--- mozjs-52.4.0/config/tests/unit-expandlibs.py	(original)
+++ mozjs-52.4.0/config/tests/unit-expandlibs.py	(refactored)
@@ -7,7 +7,7 @@
 from shutil import rmtree
 import mozunit
 
-from UserString import UserString
+from collections import UserString
 # Create a controlled configuration for use by expandlibs
 config_win = {
     'AR': 'lib',
@@ -120,8 +120,7 @@
             del dict[name]
         return type.__new__(cls, clsName, bases, dict)
 
-class TestCaseWithTmpDir(unittest.TestCase):
-    __metaclass__ = ReplicateTests
+class TestCaseWithTmpDir(unittest.TestCase, metaclass=ReplicateTests):
     def init(self):
         self.tmpdir = os.path.abspath(mkdtemp(dir=os.curdir))
 
--- mozjs-52.4.0/config/tests/unit-nsinstall.py	(original)
+++ mozjs-52.4.0/config/tests/unit-nsinstall.py	(refactored)
@@ -28,9 +28,9 @@
         # Unicode strings means non-ASCII children can be deleted properly on
         # Windows
         if sys.stdin.encoding is None:
-            tmpdir = unicode(self.tmpdir)
+            tmpdir = str(self.tmpdir)
         else:
-            tmpdir = unicode(self.tmpdir, sys.stdin.encoding)
+            tmpdir = str(self.tmpdir, sys.stdin.encoding)
         rmtree(tmpdir)
 
     # utility methods for tests
@@ -50,14 +50,14 @@
         "Test nsinstall -D <dir>"
         testdir = os.path.join(self.tmpdir, "test")
         self.assertEqual(nsinstall(["-D", testdir]), 0)
-        self.assert_(os.path.isdir(testdir))
+        self.assertTrue(os.path.isdir(testdir))
 
     def test_nsinstall_basic(self):
         "Test nsinstall <file> <dir>"
         testfile = self.touch("testfile")
         testdir = self.mkdirs("testdir")
         self.assertEqual(nsinstall([testfile, testdir]), 0)
-        self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
+        self.assertTrue(os.path.isfile(os.path.join(testdir, "testfile")))
 
     def test_nsinstall_basic_recursive(self):
         "Test nsinstall <dir> <dest dir>"
@@ -76,12 +76,12 @@
                                     '-X', Xdir]), 0)
 
         testdir = os.path.join(destdir, "sourcedir")
-        self.assert_(os.path.isdir(testdir))
-        self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
-        self.assert_(not os.path.exists(os.path.join(testdir, "Xfile")))
-        self.assert_(os.path.isdir(os.path.join(testdir, "copieddir")))
-        self.assert_(os.path.isfile(os.path.join(testdir, "copieddir", "testfile2")))
-        self.assert_(not os.path.exists(os.path.join(testdir, "Xdir")))
+        self.assertTrue(os.path.isdir(testdir))
+        self.assertTrue(os.path.isfile(os.path.join(testdir, "testfile")))
+        self.assertTrue(not os.path.exists(os.path.join(testdir, "Xfile")))
+        self.assertTrue(os.path.isdir(os.path.join(testdir, "copieddir")))
+        self.assertTrue(os.path.isfile(os.path.join(testdir, "copieddir", "testfile2")))
+        self.assertTrue(not os.path.exists(os.path.join(testdir, "Xdir")))
 
     def test_nsinstall_multiple(self):
         "Test nsinstall <three files> <dest dir>"
@@ -91,7 +91,7 @@
         testdir = self.mkdirs("testdir")
         self.assertEqual(nsinstall(testfiles + [testdir]), 0)
         for f in testfiles:
-            self.assert_(os.path.isfile(os.path.join(testdir,
+            self.assertTrue(os.path.isfile(os.path.join(testdir,
                                                      os.path.basename(f))))
 
     def test_nsinstall_dir_exists(self):
@@ -99,7 +99,7 @@
         srcdir = self.mkdirs("test")
         destdir = self.mkdirs("testdir/test")
         self.assertEqual(nsinstall([srcdir, os.path.dirname(destdir)]), 0)
-        self.assert_(os.path.isdir(destdir))
+        self.assertTrue(os.path.isdir(destdir))
 
     def test_nsinstall_t(self):
         "Test that nsinstall -t works (preserve timestamp)"
@@ -110,7 +110,7 @@
         os.utime(testfile, (t, t))
         self.assertEqual(nsinstall(["-t", testfile, testdir]), 0)
         destfile = os.path.join(testdir, "testfile")
-        self.assert_(os.path.isfile(destfile))
+        self.assertTrue(os.path.isfile(destfile))
         self.assertEqual(os.stat(testfile).st_mtime,
                          os.stat(destfile).st_mtime)
 
@@ -125,7 +125,7 @@
             self.assertEqual(nsinstall(["-m", "{0:04o}"
                                         .format(mode), testfile, testdir]), 0)
             destfile = os.path.join(testdir, "testfile")
-            self.assert_(os.path.isfile(destfile))
+            self.assertTrue(os.path.isfile(destfile))
             self.assertEqual(os.stat(testfile).st_mode,
                              os.stat(destfile).st_mode)
 
@@ -136,25 +136,25 @@
         testdir = self.mkdirs("testdir")
         destdir = os.path.join(testdir, "subdir")
         self.assertEqual(nsinstall(["-d", testfile, destdir]), 0)
-        self.assert_(os.path.isdir(os.path.join(destdir, "testfile")))
+        self.assertTrue(os.path.isdir(os.path.join(destdir, "testfile")))
 
     if RUN_NON_ASCII_TESTS:
         def test_nsinstall_non_ascii(self):
             "Test that nsinstall handles non-ASCII files"
-            filename = u"\u2325\u3452\u2415\u5081"
+            filename = "\u2325\u3452\u2415\u5081"
             testfile = self.touch(filename)
-            testdir = self.mkdirs(u"\u4241\u1D04\u1414")
+            testdir = self.mkdirs("\u4241\u1D04\u1414")
             self.assertEqual(nsinstall([testfile.encode("utf-8"),
                                         testdir.encode("utf-8")]), 0)
 
             destfile = os.path.join(testdir, filename)
-            self.assert_(os.path.isfile(destfile))
+            self.assertTrue(os.path.isfile(destfile))
 
         def test_nsinstall_non_ascii_subprocess(self):
             "Test that nsinstall as a subprocess handles non-ASCII files"
-            filename = u"\u2325\u3452\u2415\u5081"
+            filename = "\u2325\u3452\u2415\u5081"
             testfile = self.touch(filename)
-            testdir = self.mkdirs(u"\u4241\u1D04\u1414")
+            testdir = self.mkdirs("\u4241\u1D04\u1414")
             # We don't use subprocess because it can't handle Unicode on
             # Windows <http://bugs.python.org/issue1759845>. mozprocess calls
             # CreateProcessW directly so it's perfect.
@@ -166,7 +166,7 @@
 
             self.assertEqual(rv, 0)
             destfile = os.path.join(testdir, filename)
-            self.assert_(os.path.isfile(destfile))
+            self.assertTrue(os.path.isfile(destfile))
 
     #TODO: implement -R, -l, -L and test them!
 
--- mozjs-52.4.0/config/tests/unitMozZipFile.py	(original)
+++ mozjs-52.4.0/config/tests/unitMozZipFile.py	(refactored)
@@ -11,6 +11,7 @@
 import random
 import copy
 from string import letters
+from functools import reduce
 
 '''
 Test case infrastructure for MozZipFile.
@@ -38,7 +39,7 @@
   'firstdir/oneleaf',
   'seconddir/twoleaf',
   'thirddir/with/sub/threeleaf')
-_lengths = map(lambda n: n * 64, [16, 64, 80])
+_lengths = [n * 64 for n in [16, 64, 80]]
 lengths = 3
 writes = 5
 
@@ -71,7 +72,7 @@
 def getContent(length):
   'Get pseudo random content of given length.'
   rv = [None] * length
-  for i in xrange(length):
+  for i in range(length):
     rv[i] = random.choice(letters)
   return ''.join(rv)
 
@@ -133,13 +134,13 @@
   def _verifyZip(self):
     zf = zipfile.ZipFile(self.f)
     badEntry = zf.testzip()
-    self.failIf(badEntry, badEntry)
+    self.assertFalse(badEntry, badEntry)
     zlist = zf.namelist()
     zlist.sort()
-    vlist = self.ref.keys()
+    vlist = list(self.ref.keys())
     vlist.sort()
     self.assertEqual(zlist, vlist)
-    for leaf, content in self.ref.iteritems():
+    for leaf, content in self.ref.items():
       zcontent = zf.read(leaf)
       self.assertEqual(content, zcontent)
   
@@ -158,16 +159,16 @@
     open(self.leaf('stage', leaf), 'w').write(content)
 
 # all leafs in all lengths
-atomics = list(prod(xrange(len(leafs)), xrange(lengths)))
+atomics = list(prod(range(len(leafs)), range(lengths)))
 
 # populate TestExtensiveStore with testcases
-for w in xrange(writes):
+for w in range(writes):
   # Don't iterate over all files for the the first n passes,
   # those are redundant as long as w < lengths.
   # There are symmetries in the trailing end, too, but I don't know
   # how to reduce those out right now.
-  nonatomics = [list(prod(range(min(i,len(leafs))), xrange(lengths)))
-                for i in xrange(1, w+1)] + [atomics]
+  nonatomics = [list(prod(list(range(min(i,len(leafs)))), range(lengths)))
+                for i in range(1, w+1)] + [atomics]
   for descs in prod(*nonatomics):
     suffix = getid(descs)
     dicts = [dict(leaf=leaf, length=length) for leaf, length in descs]
@@ -181,9 +182,9 @@
 # and then write all atomics again.
 # This should catch more or less all artifacts generated
 # by the final ordering step when closing the jar.
-files = [list(prod([i], xrange(lengths))) for i in xrange(len(leafs))]
+files = [list(prod([i], range(lengths))) for i in range(len(leafs))]
 allfiles = reduce(lambda l,r:l+r,
-                  [list(prod(*files[:(i+1)])) for i in xrange(len(leafs))])
+                  [list(prod(*files[:(i+1)])) for i in range(len(leafs))])
 
 for first in allfiles:
   testbasename = 'test{0}_'.format(getid(first))
--- mozjs-52.4.0/config/expandlibs_exec.py.old	2018-07-11 05:07:18.280000000 +0000
+++ mozjs-52.4.0/config/expandlibs_exec.py	2018-07-11 05:08:45.670000000 +0000
@@ -344,7 +344,7 @@
         (stdout, stderr) = proc.communicate()
         if proc.returncode and not options.verbose:
             print_command(sys.stderr, args)
-        sys.stderr.write(stdout)
+        sys.stderr.write(stdout.decode('utf-8'))
         sys.stderr.flush()
         if proc.returncode:
             return proc.returncode
--- mozjs-52.4.0/js/src/builtin/embedjs.py	(original)
+++ mozjs-52.4.0/js/src/builtin/embedjs.py	(refactored)
@@ -36,7 +36,7 @@
 #
 # It uses the C preprocessor to process its inputs.
 
-from __future__ import with_statement
+
 import re, sys, os, subprocess
 import shlex
 import which
@@ -109,7 +109,7 @@
 
   with open(tmpIn, 'wb') as input:
     input.write(source)
-  print(' '.join(cxx + outputArg + args + [tmpIn]))
+  print((' '.join(cxx + outputArg + args + [tmpIn])))
   result = subprocess.Popen(cxx + outputArg + args + [tmpIn]).wait()
   if (result != 0):
     sys.exit(result);
@@ -132,7 +132,7 @@
 
 def get_config_defines(buildconfig):
   # Collect defines equivalent to ACDEFINES and add MOZ_DEBUG_DEFINES.
-  env = {key: value for key, value in buildconfig.defines.iteritems()
+  env = {key: value for key, value in buildconfig.defines.items()
          if key not in buildconfig.non_global_defines}
   for define in buildconfig.substs['MOZ_DEBUG_DEFINES']:
     env[define] = 1
--- mozjs-52.4.0/js/src/builtin/embedjs.py.old	2018-07-11 05:13:28.920000000 +0000
+++ mozjs-52.4.0/js/src/builtin/embedjs.py	2018-07-11 05:15:15.390000000 +0000
@@ -107,7 +107,7 @@
   tmpOut = 'self-hosting-preprocessed.pp';
   outputArg = shlex.split(preprocessorOption + tmpOut)
 
-  with open(tmpIn, 'wb') as input:
+  with open(tmpIn, 'w') as input:
     input.write(source)
   print((' '.join(cxx + outputArg + args + [tmpIn])))
   result = subprocess.Popen(cxx + outputArg + args + [tmpIn]).wait()
--- mozjs-52.4.0/python/mozbuild/mozbuild/preprocessor.py.old	2018-07-11 05:15:42.900000000 +0000
+++ mozjs-52.4.0/python/mozbuild/mozbuild/preprocessor.py	2018-07-11 05:23:10.870000000 +0000
@@ -451,7 +451,7 @@
                 except OSError as error:
                     if error.errno != errno.EEXIST:
                         raise
-            return open(path, 'wb')
+            return open(path, 'w')
 
         p = self.getCommandLineParser()
         options, args = p.parse_args(args=args)
--- mozjs-52.4.0/js/src/builtin/embedjs.py.old	2018-07-11 05:15:42.950000000 +0000
+++ mozjs-52.4.0/js/src/builtin/embedjs.py	2018-07-11 05:20:14.280000000 +0000
@@ -53,7 +53,7 @@
 def ToCArray(lines):
   result = []
   for chr in lines:
-    result.append(str(ord(chr)))
+    result.append(str(chr))
   return ", ".join(result)
 
 HEADER_TEMPLATE = """\
@@ -87,7 +87,7 @@
 
   js_out.write(processed)
   import zlib
-  compressed = zlib.compress(processed)
+  compressed = zlib.compress(processed.encode('utf-8'))
   data = ToCArray(compressed)
   c_out.write(HEADER_TEMPLATE % {
     'sources_type': 'unsigned char',