archrelease: copy trunk to extra-x86_64
[arch-packages.git] / qt5-webengine / repos / extra-x86_64 / qt5-webengine-chromium-python3.patch
blobc55225b683adf4a103a22d91e8172fe3b8bfe9b8
1 diff --git a/chromium/build/print_python_deps.py b/chromium/build/print_python_deps.py
2 index fd29c0972c9..69af247094b 100755
3 --- a/chromium/build/print_python_deps.py
4 +++ b/chromium/build/print_python_deps.py
5 @@ -1,4 +1,4 @@
6 -#!/usr/bin/python2.7
7 +#!/usr/bin/python
8 # Copyright 2016 The Chromium Authors. All rights reserved.
9 # Use of this source code is governed by a BSD-style license that can be
10 # found in the LICENSE file.
11 @@ -80,7 +80,7 @@ def _GetTargetPythonVersion(module):
12 if shebang.startswith('#!'):
13 # Examples:
14 # '#!/usr/bin/python'
15 - # '#!/usr/bin/python2.7'
16 + # '#!/usr/bin/python'
17 # '#!/usr/bin/python3'
18 # '#!/usr/bin/env python3'
19 # '#!/usr/bin/env vpython'
20 @@ -152,7 +152,7 @@ def main():
22 # Trybots run with vpython as default Python, but with a different config
23 # from //.vpython. To make the is_vpython test work, and to match the behavior
24 - # of dev machines, the shebang line must be run with python2.7.
25 + # of dev machines, the shebang line must be run with python.
27 # E.g. $HOME/.vpython-root/dd50d3/bin/python
28 # E.g. /b/s/w/ir/cache/vpython/ab5c79/bin/python
29 diff --git a/chromium/components/resources/protobufs/binary_proto_generator.py b/chromium/components/resources/protobufs/binary_proto_generator.py
30 index 7422ead9697..16365515f26 100755
31 --- a/chromium/components/resources/protobufs/binary_proto_generator.py
32 +++ b/chromium/components/resources/protobufs/binary_proto_generator.py
33 @@ -7,7 +7,7 @@
34 Converts a given ASCII proto into a binary resource.
36 """
38 +from __future__ import print_function
39 import abc
40 import imp
41 import optparse
42 @@ -196,12 +196,12 @@ class BinaryProtoGenerator:
43 self._ImportProtoModules(opts.path)
45 if not self.VerifyArgs(opts):
46 - print "Wrong arguments"
47 + print("Wrong arguments")
48 return 1
50 try:
51 self._GenerateBinaryProtos(opts)
52 except Exception as e:
53 - print "ERROR: Failed to render binary version of %s:\n %s\n%s" % (
54 - opts.infile, str(e), traceback.format_exc())
55 + print("ERROR: Failed to render binary version of %s:\n %s\n%s" %
56 + (opts.infile, str(e), traceback.format_exc()))
57 return 1
58 diff --git a/chromium/content/browser/tracing/generate_trace_viewer_grd.py b/chromium/content/browser/tracing/generate_trace_viewer_grd.py
59 index 037f9497dc2..be393d21f90 100755
60 --- a/chromium/content/browser/tracing/generate_trace_viewer_grd.py
61 +++ b/chromium/content/browser/tracing/generate_trace_viewer_grd.py
62 @@ -74,7 +74,7 @@ def main(argv):
63 for filename in parsed_args.source_files:
64 add_file_to_grd(doc, os.path.basename(filename))
66 - with open(parsed_args.output_filename, 'w') as output_file:
67 + with open(parsed_args.output_filename, 'wb') as output_file:
68 output_file.write(doc.toxml(encoding='UTF-8'))
71 diff --git a/chromium/mojo/public/tools/bindings/BUILD.gn b/chromium/mojo/public/tools/bindings/BUILD.gn
72 index fc04b5dd0b1..708958e438b 100644
73 --- a/chromium/mojo/public/tools/bindings/BUILD.gn
74 +++ b/chromium/mojo/public/tools/bindings/BUILD.gn
75 @@ -2,9 +2,11 @@
76 # Use of this source code is governed by a BSD-style license that can be
77 # found in the LICENSE file.
79 +import("//build/config/python.gni")
80 import("//mojo/public/tools/bindings/mojom.gni")
81 import("//third_party/jinja2/jinja2.gni")
83 +# TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
84 action("precompile_templates") {
85 sources = mojom_generator_sources
86 sources += [
87 diff --git a/chromium/mojo/public/tools/bindings/gen_data_files_list.py b/chromium/mojo/public/tools/bindings/gen_data_files_list.py
88 index 79c9e50efce..8b78d092418 100644
89 --- a/chromium/mojo/public/tools/bindings/gen_data_files_list.py
90 +++ b/chromium/mojo/public/tools/bindings/gen_data_files_list.py
91 @@ -18,7 +18,6 @@ import os
92 import re
93 import sys
95 -from cStringIO import StringIO
96 from optparse import OptionParser
98 sys.path.insert(
99 @@ -41,12 +40,9 @@ def main():
100 pattern = re.compile(options.pattern)
101 files = [f for f in os.listdir(options.directory) if pattern.match(f)]
103 - stream = StringIO()
104 - for f in files:
105 - print(f, file=stream)
106 + contents = '\n'.join(f for f in files) + '\n'
107 + WriteFile(contents, options.output)
109 - WriteFile(stream.getvalue(), options.output)
110 - stream.close()
112 if __name__ == '__main__':
113 sys.exit(main())
114 diff --git a/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py b/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py
115 index 96b2fdfae0c..00b9dccd00c 100644
116 --- a/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py
117 +++ b/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py
118 @@ -25,6 +25,10 @@ sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir,
119 'build', 'android', 'gyp'))
120 from util import build_utils
122 +# TODO(crbug.com/1174969): Remove this once Python2 is obsoleted.
123 +if sys.version_info.major != 2:
124 + basestring = str
125 + long = int
127 GENERATOR_PREFIX = 'java'
129 diff --git a/chromium/mojo/public/tools/mojom/mojom/generate/generator.py b/chromium/mojo/public/tools/mojom/mojom/generate/generator.py
130 index de62260a5c9..4a1c73fcf82 100644
131 --- a/chromium/mojo/public/tools/mojom/mojom/generate/generator.py
132 +++ b/chromium/mojo/public/tools/mojom/mojom/generate/generator.py
133 @@ -136,9 +136,14 @@ class Stylizer(object):
135 def WriteFile(contents, full_path):
136 # If |contents| is same with the file content, we skip updating.
137 + if not isinstance(contents, bytes):
138 + data = contents.encode('utf8')
139 + else:
140 + data = contents
142 if os.path.isfile(full_path):
143 with open(full_path, 'rb') as destination_file:
144 - if destination_file.read() == contents:
145 + if destination_file.read() == data:
146 return
148 # Make sure the containing directory exists.
149 @@ -146,11 +151,8 @@ def WriteFile(contents, full_path):
150 fileutil.EnsureDirectoryExists(full_dir)
152 # Dump the data to disk.
153 - with open(full_path, "wb") as f:
154 - if not isinstance(contents, bytes):
155 - f.write(contents.encode('utf-8'))
156 - else:
157 - f.write(contents)
158 + with open(full_path, 'wb') as f:
159 + f.write(data)
162 def AddComputedData(module):
163 diff --git a/chromium/mojo/public/tools/mojom/mojom/generate/module.py b/chromium/mojo/public/tools/mojom/mojom/generate/module.py
164 index ebbc9b322ea..3d026429bbc 100644
165 --- a/chromium/mojo/public/tools/mojom/mojom/generate/module.py
166 +++ b/chromium/mojo/public/tools/mojom/mojom/generate/module.py
167 @@ -398,7 +398,8 @@ class Field(object):
170 class StructField(Field):
171 - pass
172 + def __hash__(self):
173 + return super(Field, self).__hash__()
176 class UnionField(Field):
177 diff --git a/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py b/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py
178 index 7a300560246..8d9e26fb7f6 100644
179 --- a/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py
180 +++ b/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py
181 @@ -75,9 +75,9 @@ def PrecompileTemplates(generator_modules, output_dir):
182 os.path.dirname(module.__file__), generator.GetTemplatePrefix())
184 jinja_env.filters.update(generator.GetFilters())
185 - jinja_env.compile_templates(
186 - os.path.join(output_dir, "%s.zip" % generator.GetTemplatePrefix()),
187 - extensions=["tmpl"],
188 - zip="stored",
189 - py_compile=True,
190 - ignore_errors=False)
191 + jinja_env.compile_templates(os.path.join(
192 + output_dir, "%s.zip" % generator.GetTemplatePrefix()),
193 + extensions=["tmpl"],
194 + zip="stored",
195 + py_compile=sys.version_info.major < 3,
196 + ignore_errors=False)
197 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py
198 index 3225ecca6e4..fc078d31b55 100644
199 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py
200 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py
201 @@ -344,7 +344,7 @@ def make_default_value_expr(idl_type, default_value):
203 assert default_value.is_type_compatible_with(idl_type)
205 - class DefaultValueExpr:
206 + class DefaultValueExpr(object):
207 _ALLOWED_SYMBOLS_IN_DEPS = ("isolate")
209 def __init__(self, initializer_expr, initializer_deps,
210 @@ -502,7 +502,7 @@ def make_v8_to_blink_value(blink_var_name,
211 assert isinstance(blink_var_name, str)
212 assert isinstance(v8_value_expr, str)
213 assert isinstance(idl_type, web_idl.IdlType)
214 - assert (argument_index is None or isinstance(argument_index, (int, long)))
215 + assert (argument_index is None or isinstance(argument_index, int))
216 assert (default_value is None
217 or isinstance(default_value, web_idl.LiteralConstant))
219 @@ -622,7 +622,7 @@ def make_v8_to_blink_value_variadic(blink_var_name, v8_array,
221 assert isinstance(blink_var_name, str)
222 assert isinstance(v8_array, str)
223 - assert isinstance(v8_array_start_index, (int, long))
224 + assert isinstance(v8_array_start_index, int)
225 assert isinstance(idl_type, web_idl.IdlType)
227 pattern = ("auto&& ${{{_1}}} = "
228 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py
229 index 4a6df513068..8b51f23a409 100644
230 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py
231 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py
232 @@ -177,7 +177,7 @@ def generate_callback_interface(callback_interface_identifier):
233 prop_install_mode=PropInstallMode.UNCONDITIONAL,
234 trampoline_var_name=None,
235 attribute_entries=[],
236 - constant_entries=filter(is_unconditional, constant_entries),
237 + constant_entries=list(filter(is_unconditional, constant_entries)),
238 exposed_construct_entries=[],
239 operation_entries=[])
240 (install_interface_template_decl, install_interface_template_def,
241 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py
242 index 52972fefe20..e5ae9d9629e 100644
243 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py
244 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py
245 @@ -503,13 +503,13 @@ class CompositeNode(CodeNode):
246 gensym_kwargs = {}
247 template_vars = {}
248 for arg in args:
249 - assert isinstance(arg, (CodeNode, int, long, str))
250 + assert isinstance(arg, (CodeNode, int, str))
251 gensym = CodeNode.gensym()
252 gensym_args.append("${{{}}}".format(gensym))
253 template_vars[gensym] = arg
254 for key, value in kwargs.items():
255 - assert isinstance(key, (int, long, str))
256 - assert isinstance(value, (CodeNode, int, long, str))
257 + assert isinstance(key, (int, str))
258 + assert isinstance(value, (CodeNode, int, str))
259 gensym = CodeNode.gensym()
260 gensym_kwargs[key] = "${{{}}}".format(gensym)
261 template_vars[gensym] = value
262 @@ -602,7 +602,7 @@ class ListNode(CodeNode):
263 def insert(self, index, node):
264 if node is None:
265 return
266 - assert isinstance(index, (int, long))
267 + assert isinstance(index, int)
268 assert isinstance(node, CodeNode)
269 assert node.outer is None and node.prev is None
271 @@ -721,7 +721,7 @@ class SymbolScopeNode(SequenceNode):
272 if not scope_chains:
273 return counts
275 - self_index = iter(scope_chains).next().index(self)
276 + self_index = next(iter(scope_chains)).index(self)
277 scope_chains = map(
278 lambda scope_chain: scope_chain[self_index + 1:], scope_chains)
279 scope_to_likeliness = {}
280 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py
281 index a229a6c71c9..5fa288dabf2 100644
282 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py
283 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py
284 @@ -109,7 +109,7 @@ def expr_and(terms):
286 if any(term.is_always_false for term in terms):
287 return _Expr(False)
288 - terms = filter(lambda x: not x.is_always_true, terms)
289 + terms = list(filter(lambda x: not x.is_always_true, terms))
290 if not terms:
291 return _Expr(True)
292 if len(terms) == 1:
293 @@ -124,7 +124,7 @@ def expr_or(terms):
295 if any(term.is_always_true for term in terms):
296 return _Expr(True)
297 - terms = filter(lambda x: not x.is_always_false, terms)
298 + terms = list(filter(lambda x: not x.is_always_false, terms))
299 if not terms:
300 return _Expr(False)
301 if len(terms) == 1:
302 @@ -222,7 +222,7 @@ def expr_from_exposure(exposure,
303 elif exposure.only_in_secure_contexts is False:
304 secure_context_term = _Expr(True)
305 else:
306 - terms = map(ref_enabled, exposure.only_in_secure_contexts)
307 + terms = list(map(ref_enabled, exposure.only_in_secure_contexts))
308 secure_context_term = expr_or(
309 [_Expr("${is_in_secure_context}"),
310 expr_not(expr_and(terms))])
311 @@ -275,10 +275,11 @@ def expr_from_exposure(exposure,
313 # [ContextEnabled]
314 if exposure.context_enabled_features:
315 - terms = map(
316 - lambda feature: _Expr(
317 - "${{context_feature_settings}}->is{}Enabled()".format(
318 - feature)), exposure.context_enabled_features)
319 + terms = list(
320 + map(
321 + lambda feature: _Expr(
322 + "${{context_feature_settings}}->is{}Enabled()".format(
323 + feature)), exposure.context_enabled_features))
324 context_enabled_terms.append(
325 expr_and([_Expr("${context_feature_settings}"),
326 expr_or(terms)]))
327 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py
328 index 87d26eec3ca..f3e9d38247e 100644
329 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py
330 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py
331 @@ -23,7 +23,7 @@ class _TemplateFormatter(string.Formatter):
332 self._template_formatter_indexing_count_ = 0
334 def get_value(self, key, args, kwargs):
335 - if isinstance(key, (int, long)):
336 + if isinstance(key, int):
337 return args[key]
338 assert isinstance(key, str)
339 if not key:
340 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py
341 index 2bcc4fed49a..e72282aa696 100644
342 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py
343 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py
344 @@ -116,4 +116,4 @@ def write_code_node_to_file(code_node, filepath):
345 # stderr=format_result.error_message))
347 # web_idl.file_io.write_to_file_if_changed(filepath, format_result.contents)
348 - web_idl.file_io.write_to_file_if_changed(filepath, rendered_text)
349 + web_idl.file_io.write_to_file_if_changed(filepath, rendered_text.encode('utf-8'))
350 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py
351 index b39f0100410..4d68202296b 100644
352 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py
353 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py
354 @@ -993,7 +993,7 @@ def make_dict_trace_func(cg_context):
355 _2 = _blink_member_name(member).value_var
356 return TextNode(_format(pattern, _1=_1, _2=_2))
358 - body.extend(map(make_trace_member_node, own_members))
359 + body.extend(list(map(make_trace_member_node, own_members)))
360 body.append(TextNode("BaseClass::Trace(visitor);"))
362 return func_decl, func_def
363 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
364 index 10ff30656ad..bfdf7128aac 100644
365 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
366 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
367 @@ -582,7 +582,7 @@ def _make_blink_api_call(code_node,
368 overriding_args=None):
369 assert isinstance(code_node, SymbolScopeNode)
370 assert isinstance(cg_context, CodeGenContext)
371 - assert num_of_args is None or isinstance(num_of_args, (int, long))
372 + assert num_of_args is None or isinstance(num_of_args, int)
373 assert (overriding_args is None
374 or (isinstance(overriding_args, (list, tuple))
375 and all(isinstance(arg, str) for arg in overriding_args)))
376 @@ -1196,8 +1196,10 @@ def make_overload_dispatcher(cg_context):
377 did_use_break = did_use_break or can_fail
379 conditional = expr_or(
380 - map(lambda item: expr_from_exposure(item.function_like.exposure),
381 - items))
382 + list(
383 + map(
384 + lambda item: expr_from_exposure(item.function_like.exposure
385 + ), items)))
386 if not conditional.is_always_true:
387 node = CxxUnlikelyIfNode(cond=conditional, body=node)
389 @@ -4642,7 +4644,7 @@ class _PropEntryConstructorGroup(_PropEntryBase):
390 def __init__(self, is_context_dependent, exposure_conditional, world,
391 constructor_group, ctor_callback_name, ctor_func_length):
392 assert isinstance(ctor_callback_name, str)
393 - assert isinstance(ctor_func_length, (int, long))
394 + assert isinstance(ctor_func_length, int)
396 _PropEntryBase.__init__(self, is_context_dependent,
397 exposure_conditional, world, constructor_group)
398 @@ -4670,7 +4672,7 @@ class _PropEntryOperationGroup(_PropEntryBase):
399 op_func_length,
400 no_alloc_direct_callback_name=None):
401 assert isinstance(op_callback_name, str)
402 - assert isinstance(op_func_length, (int, long))
403 + assert isinstance(op_func_length, int)
405 _PropEntryBase.__init__(self, is_context_dependent,
406 exposure_conditional, world, operation_group)
407 @@ -5175,9 +5177,9 @@ def make_install_interface_template(cg_context, function_name, class_name, api_c
410 if class_like.identifier == "CSSStyleDeclaration":
411 - css_properties = filter(
412 - lambda attr: "CSSProperty" in attr.extended_attributes,
413 - class_like.attributes)
414 + css_properties = list(
415 + filter(lambda attr: "CSSProperty" in attr.extended_attributes,
416 + class_like.attributes))
417 if css_properties:
418 prop_name_list = "".join(
419 map(lambda attr: "\"{}\", ".format(attr.identifier),
420 @@ -5567,8 +5569,8 @@ ${instance_object} = ${v8_context}->Global()->GetPrototype().As<v8::Object>();\
421 "V8DOMConfiguration::InstallConstants(${isolate}, "
422 "${interface_template}, ${prototype_template}, "
423 "kConstantCallbackTable, base::size(kConstantCallbackTable));")
424 - constant_callback_entries = filter(lambda entry: entry.const_callback_name,
425 - constant_entries)
426 + constant_callback_entries = list(filter(lambda entry: entry.const_callback_name,
427 + constant_entries))
428 install_properties(table_name, constant_callback_entries,
429 _make_constant_callback_registration_table,
430 installer_call_text)
431 @@ -5584,8 +5586,8 @@ ${instance_object} = ${v8_context}->Global()->GetPrototype().As<v8::Object>();\
432 "V8DOMConfiguration::InstallConstants(${isolate}, "
433 "${interface_template}, ${prototype_template}, "
434 "kConstantValueTable, base::size(kConstantValueTable));")
435 - constant_value_entries = filter(
436 - lambda entry: not entry.const_callback_name, constant_entries)
437 + constant_value_entries = list(filter(
438 + lambda entry: not entry.const_callback_name, constant_entries))
439 install_properties(table_name, constant_value_entries,
440 _make_constant_value_registration_table,
441 installer_call_text)
442 @@ -6336,8 +6338,8 @@ def make_v8_context_snapshot_api(cg_context, component, attribute_entries,
443 assert isinstance(component, web_idl.Component)
445 derived_interfaces = cg_context.interface.deriveds
446 - derived_names = map(lambda interface: interface.identifier,
447 - derived_interfaces)
448 + derived_names = list(
449 + map(lambda interface: interface.identifier, derived_interfaces))
450 derived_names.append(cg_context.interface.identifier)
451 if not ("Window" in derived_names or "HTMLDocument" in derived_names):
452 return None, None
453 @@ -6411,9 +6413,11 @@ def _make_v8_context_snapshot_get_reference_table_function(
454 collect_callbacks(named_properties_object_callback_defs)
455 collect_callbacks(cross_origin_property_callback_defs)
457 - entry_nodes = map(
458 - lambda name: TextNode("reinterpret_cast<intptr_t>({}),".format(name)),
459 - filter(None, callback_names))
460 + entry_nodes = list(
461 + map(
462 + lambda name: TextNode("reinterpret_cast<intptr_t>({}),".format(name
463 + )),
464 + filter(None, callback_names)))
465 table_node = ListNode([
466 TextNode("using namespace ${class_name}Callbacks;"),
467 TextNode("static const intptr_t kReferenceTable[] = {"),
468 @@ -6451,10 +6455,11 @@ def _make_v8_context_snapshot_install_props_per_context_function(
469 class_name=None,
470 prop_install_mode=PropInstallMode.V8_CONTEXT_SNAPSHOT,
471 trampoline_var_name=None,
472 - attribute_entries=filter(selector, attribute_entries),
473 - constant_entries=filter(selector, constant_entries),
474 - exposed_construct_entries=filter(selector, exposed_construct_entries),
475 - operation_entries=filter(selector, operation_entries))
476 + attribute_entries=list(filter(selector, attribute_entries)),
477 + constant_entries=list(filter(selector, constant_entries)),
478 + exposed_construct_entries=list(
479 + filter(selector, exposed_construct_entries)),
480 + operation_entries=list(filter(selector, operation_entries)))
482 return func_decl, func_def
484 @@ -6810,11 +6815,11 @@ def generate_interface(interface_identifier):
485 class_name=impl_class_name,
486 prop_install_mode=PropInstallMode.UNCONDITIONAL,
487 trampoline_var_name=tp_install_unconditional_props,
488 - attribute_entries=filter(is_unconditional, attribute_entries),
489 - constant_entries=filter(is_unconditional, constant_entries),
490 - exposed_construct_entries=filter(is_unconditional,
491 - exposed_construct_entries),
492 - operation_entries=filter(is_unconditional, operation_entries))
493 + attribute_entries=list(filter(is_unconditional, attribute_entries)),
494 + constant_entries=list(filter(is_unconditional, constant_entries)),
495 + exposed_construct_entries=list(
496 + filter(is_unconditional, exposed_construct_entries)),
497 + operation_entries=list(filter(is_unconditional, operation_entries)))
498 (install_context_independent_props_decl,
499 install_context_independent_props_def,
500 install_context_independent_props_trampoline) = make_install_properties(
501 @@ -6823,11 +6828,14 @@ def generate_interface(interface_identifier):
502 class_name=impl_class_name,
503 prop_install_mode=PropInstallMode.CONTEXT_INDEPENDENT,
504 trampoline_var_name=tp_install_context_independent_props,
505 - attribute_entries=filter(is_context_independent, attribute_entries),
506 - constant_entries=filter(is_context_independent, constant_entries),
507 - exposed_construct_entries=filter(is_context_independent,
508 - exposed_construct_entries),
509 - operation_entries=filter(is_context_independent, operation_entries))
510 + attribute_entries=list(
511 + filter(is_context_independent, attribute_entries)),
512 + constant_entries=list(filter(is_context_independent,
513 + constant_entries)),
514 + exposed_construct_entries=list(
515 + filter(is_context_independent, exposed_construct_entries)),
516 + operation_entries=list(
517 + filter(is_context_independent, operation_entries)))
518 (install_context_dependent_props_decl, install_context_dependent_props_def,
519 install_context_dependent_props_trampoline) = make_install_properties(
520 cg_context,
521 @@ -6835,11 +6843,13 @@ def generate_interface(interface_identifier):
522 class_name=impl_class_name,
523 prop_install_mode=PropInstallMode.CONTEXT_DEPENDENT,
524 trampoline_var_name=tp_install_context_dependent_props,
525 - attribute_entries=filter(is_context_dependent, attribute_entries),
526 - constant_entries=filter(is_context_dependent, constant_entries),
527 - exposed_construct_entries=filter(is_context_dependent,
528 - exposed_construct_entries),
529 - operation_entries=filter(is_context_dependent, operation_entries))
530 + attribute_entries=list(filter(is_context_dependent,
531 + attribute_entries)),
532 + constant_entries=list(filter(is_context_dependent, constant_entries)),
533 + exposed_construct_entries=list(
534 + filter(is_context_dependent, exposed_construct_entries)),
535 + operation_entries=list(filter(is_context_dependent,
536 + operation_entries)))
537 (install_interface_template_decl, install_interface_template_def,
538 install_interface_template_trampoline) = make_install_interface_template(
539 cg_context,
540 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py
541 index b4c70553863..f3a2fcd772d 100644
542 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py
543 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py
544 @@ -105,7 +105,7 @@ class MakoRenderer(object):
545 on_error = self._caller_stack_on_error
546 if (len(current) <= len(on_error)
547 and all(current[i] == on_error[i]
548 - for i in xrange(len(current)))):
549 + for i in range(len(current)))):
550 pass # Error happened in a deeper caller.
551 else:
552 self._caller_stack_on_error = list(self._caller_stack)
553 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py
554 index dc3493cc394..017d3d47bb3 100644
555 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py
556 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py
557 @@ -70,8 +70,13 @@ def gn_format(contents, filename=None):
560 def _invoke_format_command(command_line, filename, contents):
561 - proc = subprocess.Popen(
562 - command_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
563 + kwargs = {}
564 + if sys.version_info.major != 2:
565 + kwargs['encoding'] = 'utf-8'
566 + proc = subprocess.Popen(command_line,
567 + stdin=subprocess.PIPE,
568 + stdout=subprocess.PIPE,
569 + **kwargs)
570 stdout_output, stderr_output = proc.communicate(input=contents)
571 exit_code = proc.wait()
573 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py
574 index 0d8f4c0f303..e666a9b668e 100644
575 --- a/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py
576 +++ b/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py
577 @@ -2,6 +2,7 @@
578 # Use of this source code is governed by a BSD-style license that can be
579 # found in the LICENSE file.
581 +import functools
582 import multiprocessing
584 from .package_initializer import package_initializer
585 @@ -76,7 +77,7 @@ class TaskQueue(object):
586 if not report_progress:
587 return
589 - done_count = reduce(
590 + done_count = functools.reduce(
591 lambda count, worker_task: count + bool(worker_task.ready()),
592 self._worker_tasks, 0)
593 report_progress(len(self._worker_tasks), done_count)
594 @@ -85,4 +86,4 @@ class TaskQueue(object):
595 def _task_queue_run_tasks(tasks):
596 for task in tasks:
597 func, args, kwargs = task
598 - apply(func, args, kwargs)
599 + func(*args, **kwargs)
600 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py b/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py
601 index e8280be7213..e49e6eb965e 100644
602 --- a/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py
603 +++ b/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py
604 @@ -13,6 +13,7 @@ import re
605 import sys
607 from idl_types import set_ancestors, IdlType
608 +from itertools import groupby
609 from v8_globals import includes
610 from v8_interface import constant_filters
611 from v8_types import set_component_dirs
612 @@ -43,6 +44,7 @@ TEMPLATES_DIR = os.path.normpath(
613 # after path[0] == invoking script dir
614 sys.path.insert(1, THIRD_PARTY_DIR)
615 import jinja2
616 +from jinja2.filters import make_attrgetter, environmentfilter
619 def generate_indented_conditional(code, conditional):
620 @@ -88,6 +90,13 @@ def runtime_enabled_if(code, name):
621 return generate_indented_conditional(code, function)
624 +@environmentfilter
625 +def do_stringify_key_group_by(environment, value, attribute):
626 + expr = make_attrgetter(environment, attribute)
627 + key = lambda item: '' if expr(item) is None else str(expr(item))
628 + return groupby(sorted(value, key=key), expr)
631 def initialize_jinja_env(cache_dir):
632 jinja_env = jinja2.Environment(
633 loader=jinja2.FileSystemLoader(TEMPLATES_DIR),
634 @@ -117,6 +126,7 @@ def initialize_jinja_env(cache_dir):
636 jinja_env.filters.update(constant_filters())
637 jinja_env.filters.update(method_filters())
638 + jinja_env.filters["stringifykeygroupby"] = do_stringify_key_group_by
639 return jinja_env
642 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py b/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py
643 index 130004eae83..04c0fabcef2 100755
644 --- a/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py
645 +++ b/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py
646 @@ -80,7 +80,7 @@ def read_idl_file(reader, idl_filename):
647 assert len(interfaces) == 1, (
648 "Expected one interface in file %r, found %d" %
649 (idl_filename, len(interfaces)))
650 - return (interfaces.values()[0], includes)
651 + return (list(interfaces.values())[0], includes)
654 def interface_is_global(interface):
655 @@ -281,7 +281,7 @@ def main():
657 info_provider = create_component_info_provider(
658 os.path.normpath(options.info_dir), options.target_component)
659 - idl_filenames = map(str.strip, open(options.idl_files_list))
660 + idl_filenames = list(map(str.strip, open(options.idl_files_list)))
662 generate_origin_trial_features(info_provider, options, idl_filenames)
663 return 0
664 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py b/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py
665 index 14e6e9d3f87..b027818aef2 100644
666 --- a/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py
667 +++ b/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py
668 @@ -394,7 +394,8 @@ class IdlInterface(object):
669 else:
670 raise ValueError('Unrecognized node class: %s' % child_class)
672 - if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1:
673 + if len(list(filter(None,
674 + [self.iterable, self.maplike, self.setlike]))) > 1:
675 raise ValueError(
676 'Interface can only have one of iterable<>, maplike<> and setlike<>.'
678 @@ -512,6 +513,9 @@ class IdlAttribute(TypedObject):
679 def accept(self, visitor):
680 visitor.visit_attribute(self)
682 + def __lt__(self, other):
683 + return self.name < other.name
686 ################################################################################
687 # Constants
688 @@ -852,7 +856,7 @@ class IdlIncludes(object):
689 ################################################################################
692 -class Exposure:
693 +class Exposure(object):
694 """An Exposure holds one Exposed or RuntimeEnabled condition.
695 Each exposure has two properties: exposed and runtime_enabled.
696 Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to
697 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py b/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py
698 index 8d72865a6ca..b80eebdcd61 100644
699 --- a/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py
700 +++ b/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py
701 @@ -55,8 +55,8 @@ def validate_blink_idl_definitions(idl_filename, idl_file_basename,
702 definitions. There is no filename convention in this case.
703 - Otherwise, an IDL file is invalid.
705 - targets = (
706 - definitions.interfaces.values() + definitions.dictionaries.values())
707 + targets = (list(definitions.interfaces.values()) +
708 + list(definitions.dictionaries.values()))
709 number_of_targets = len(targets)
710 if number_of_targets > 1:
711 raise Exception(
712 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py b/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py
713 index cd4f0c3513b..ab95e9c0b08 100644
714 --- a/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py
715 +++ b/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py
716 @@ -349,7 +349,7 @@ class IdlUnionType(IdlTypeBase):
717 return True
719 def single_matching_member_type(self, predicate):
720 - matching_types = filter(predicate, self.flattened_member_types)
721 + matching_types = list(filter(predicate, self.flattened_member_types))
722 if len(matching_types) > 1:
723 raise ValueError('%s is ambiguous.' % self.name)
724 return matching_types[0] if matching_types else None
725 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/utilities.py b/chromium/third_party/blink/renderer/bindings/scripts/utilities.py
726 index e1677ee7bd6..3c5006f064f 100644
727 --- a/chromium/third_party/blink/renderer/bindings/scripts/utilities.py
728 +++ b/chromium/third_party/blink/renderer/bindings/scripts/utilities.py
729 @@ -196,8 +196,9 @@ class ComponentInfoProviderModules(ComponentInfoProvider):
731 @property
732 def callback_functions(self):
733 - return dict(self._component_info_core['callback_functions'].items() +
734 - self._component_info_modules['callback_functions'].items())
735 + return dict(
736 + list(self._component_info_core['callback_functions'].items()) +
737 + list(self._component_info_modules['callback_functions'].items()))
739 @property
740 def specifier_for_export(self):
741 @@ -209,8 +210,8 @@ class ComponentInfoProviderModules(ComponentInfoProvider):
744 def load_interfaces_info_overall_pickle(info_dir):
745 - with open(os.path.join(info_dir,
746 - 'interfaces_info.pickle')) as interface_info_file:
747 + with open(os.path.join(info_dir, 'interfaces_info.pickle'),
748 + mode='rb') as interface_info_file:
749 return pickle.load(interface_info_file)
752 @@ -236,23 +237,20 @@ def merge_dict_recursively(target, diff):
754 def create_component_info_provider_core(info_dir):
755 interfaces_info = load_interfaces_info_overall_pickle(info_dir)
756 - with open(
757 - os.path.join(info_dir, 'core',
758 - 'component_info_core.pickle')) as component_info_file:
759 + with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'),
760 + mode='rb') as component_info_file:
761 component_info = pickle.load(component_info_file)
762 return ComponentInfoProviderCore(interfaces_info, component_info)
765 def create_component_info_provider_modules(info_dir):
766 interfaces_info = load_interfaces_info_overall_pickle(info_dir)
767 - with open(
768 - os.path.join(info_dir, 'core',
769 - 'component_info_core.pickle')) as component_info_file:
770 + with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'),
771 + mode='rb') as component_info_file:
772 component_info_core = pickle.load(component_info_file)
773 - with open(
774 - os.path.join(
775 - info_dir, 'modules',
776 - 'component_info_modules.pickle')) as component_info_file:
777 + with open(os.path.join(info_dir, 'modules',
778 + 'component_info_modules.pickle'),
779 + mode='rb') as component_info_file:
780 component_info_modules = pickle.load(component_info_file)
781 return ComponentInfoProviderModules(interfaces_info, component_info_core,
782 component_info_modules)
783 @@ -356,7 +354,7 @@ def write_pickle_file(pickle_filename, data):
784 pickle_filename = abs(pickle_filename)
785 # If |data| is same with the file content, we skip updating.
786 if os.path.isfile(pickle_filename):
787 - with open(pickle_filename) as pickle_file:
788 + with open(pickle_filename, 'rb') as pickle_file:
789 try:
790 if pickle.load(pickle_file) == data:
791 return
792 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py b/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py
793 index a43260414db..a85b03abe75 100644
794 --- a/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py
795 +++ b/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py
796 @@ -189,7 +189,7 @@ def context_enabled_features(attributes):
797 return sorted([
798 member for member in members
799 if member.get(KEY) and not member.get('exposed_test')
800 - ])
801 + ], key=lambda item: item['name'])
803 def member_filter_by_name(members, name):
804 return [member for member in members if member[KEY] == name]
805 @@ -612,7 +612,8 @@ def interface_context(interface, interfaces, component_info):
806 sorted(
807 origin_trial_features(interface, context['constants'],
808 context['attributes'], context['methods']) +
809 - context_enabled_features(context['attributes'])),
810 + context_enabled_features(context['attributes']),
811 + key=lambda item: item['name']),
813 if context['optional_features']:
814 includes.add('platform/bindings/v8_per_context_data.h')
815 @@ -1356,9 +1357,9 @@ def resolution_tests_methods(effective_overloads):
817 # Extract argument and IDL type to simplify accessing these in each loop.
818 arguments = [method['arguments'][index] for method in methods]
819 - arguments_methods = zip(arguments, methods)
820 + arguments_methods = list(zip(arguments, methods))
821 idl_types = [argument['idl_type_object'] for argument in arguments]
822 - idl_types_methods = zip(idl_types, methods)
823 + idl_types_methods = list(zip(idl_types, methods))
825 # We can’t do a single loop through all methods or simply sort them, because
826 # a method may be listed in multiple steps of the resolution algorithm, and
827 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py b/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py
828 index 5f1f89a3def..6ee8a407798 100644
829 --- a/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py
830 +++ b/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py
831 @@ -46,6 +46,10 @@ import v8_types
832 import v8_utilities
833 from v8_utilities import (has_extended_attribute_value, is_unforgeable)
835 +# TODO: Remove this once Python2 is obsoleted.
836 +if sys.version_info.major != 2:
837 + basestring = str
840 def method_is_visible(method, interface_is_partial):
841 if 'overloads' in method:
842 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py b/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py
843 index 2ecd6923320..fcfc48371b1 100644
844 --- a/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py
845 +++ b/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py
846 @@ -271,7 +271,7 @@ EXPOSED_WORKERS = set([
850 -class ExposureSet:
851 +class ExposureSet(object):
852 """An ExposureSet is a collection of Exposure instructions."""
854 def __init__(self, exposures=None):
855 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py
856 index 13fb7c7068d..b73b7710687 100644
857 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py
858 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py
859 @@ -91,11 +91,13 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
860 for operation_ir in ir.operations
862 self._operation_groups = tuple([
863 - OperationGroup(
864 - operation_group_ir,
865 - filter(lambda x: x.identifier == operation_group_ir.identifier,
866 - self._operations),
867 - owner=self) for operation_group_ir in ir.operation_groups
868 + OperationGroup(operation_group_ir,
869 + list(
870 + filter(
871 + lambda x: x.identifier == operation_group_ir
872 + .identifier, self._operations)),
873 + owner=self)
874 + for operation_group_ir in ir.operation_groups
877 @property
878 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py
879 index c92cf48eb2a..f5d59129449 100644
880 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py
881 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py
882 @@ -156,4 +156,4 @@ class Database(object):
883 return self._view_by_kind(Database._Kind.UNION)
885 def _view_by_kind(self, kind):
886 - return self._impl.find_by_kind(kind).values()
887 + return list(self._impl.find_by_kind(kind).values())
888 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py
889 index abaeef39c30..e36cf7439ae 100644
890 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py
891 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py
892 @@ -8,8 +8,11 @@ from .runtime_enabled_features import RuntimeEnabledFeatures
893 class _Feature(str):
894 """Represents a runtime-enabled feature."""
896 + def __new__(cls, value):
897 + return str.__new__(cls, value)
899 def __init__(self, value):
900 - str.__init__(self, value)
901 + str.__init__(self)
902 self._is_context_dependent = (
903 RuntimeEnabledFeatures.is_context_dependent(self))
905 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py
906 index 648c70d803d..1712f19c672 100644
907 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py
908 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py
909 @@ -71,8 +71,9 @@ class FunctionLike(WithIdentifier):
910 def num_of_required_arguments(self):
911 """Returns the number of required arguments."""
912 return len(
913 - filter(lambda arg: not (arg.is_optional or arg.is_variadic),
914 - self.arguments))
915 + list(
916 + filter(lambda arg: not (arg.is_optional or arg.is_variadic),
917 + self.arguments)))
920 class OverloadGroup(WithIdentifier):
921 @@ -171,8 +172,7 @@ class OverloadGroup(WithIdentifier):
922 Returns the effective overload set.
923 https://heycam.github.io/webidl/#compute-the-effective-overload-set
925 - assert argument_count is None or isinstance(argument_count,
926 - (int, long))
927 + assert argument_count is None or isinstance(argument_count, int)
929 N = argument_count
930 S = []
931 @@ -188,21 +188,21 @@ class OverloadGroup(WithIdentifier):
933 S.append(
934 OverloadGroup.EffectiveOverloadItem(
935 - X, map(lambda arg: arg.idl_type, X.arguments),
936 - map(lambda arg: arg.optionality, X.arguments)))
937 + X, list(map(lambda arg: arg.idl_type, X.arguments)),
938 + list(map(lambda arg: arg.optionality, X.arguments))))
940 if X.is_variadic:
941 - for i in xrange(n, max(maxarg, N)):
942 - t = map(lambda arg: arg.idl_type, X.arguments)
943 - o = map(lambda arg: arg.optionality, X.arguments)
944 - for _ in xrange(n, i + 1):
945 + for i in range(n, max(maxarg, N)):
946 + t = list(map(lambda arg: arg.idl_type, X.arguments))
947 + o = list(map(lambda arg: arg.optionality, X.arguments))
948 + for _ in range(n, i + 1):
949 t.append(X.arguments[-1].idl_type)
950 o.append(X.arguments[-1].optionality)
951 S.append(OverloadGroup.EffectiveOverloadItem(X, t, o))
953 - t = map(lambda arg: arg.idl_type, X.arguments)
954 - o = map(lambda arg: arg.optionality, X.arguments)
955 - for i in xrange(n - 1, -1, -1):
956 + t = list(map(lambda arg: arg.idl_type, X.arguments))
957 + o = list(map(lambda arg: arg.optionality, X.arguments))
958 + for i in range(n - 1, -1, -1):
959 if X.arguments[i].optionality == IdlType.Optionality.REQUIRED:
960 break
961 S.append(OverloadGroup.EffectiveOverloadItem(X, t[:i], o[:i]))
962 @@ -222,7 +222,7 @@ class OverloadGroup(WithIdentifier):
963 for item in items)
964 assert len(items) > 1
966 - for index in xrange(len(items[0].type_list)):
967 + for index in range(len(items[0].type_list)):
968 # Assume that the given items are valid, and we only need to test
969 # the two types.
970 if OverloadGroup.are_distinguishable_types(
971 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
972 index c5ee2bd8a3d..58315072480 100644
973 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
974 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
975 @@ -149,8 +149,8 @@ class IdlCompiler(object):
976 for old_ir in old_irs:
977 new_ir = make_copy(old_ir)
978 self._ir_map.add(new_ir)
979 - new_ir.attributes = filter(not_disabled, new_ir.attributes)
980 - new_ir.operations = filter(not_disabled, new_ir.operations)
981 + new_ir.attributes = list(filter(not_disabled, new_ir.attributes))
982 + new_ir.operations = list(filter(not_disabled, new_ir.operations))
984 def _record_defined_in_partial_and_mixin(self):
985 old_irs = self._ir_map.irs_of_kinds(
986 @@ -231,7 +231,7 @@ class IdlCompiler(object):
987 only_to_members_of_partial_or_mixin=False)
988 propagate_to_exposure(propagate)
990 - map(process_member_like, ir.iter_all_members())
991 + list(map(process_member_like, ir.iter_all_members()))
993 def process_member_like(ir):
994 propagate = functools.partial(propagate_extattr, ir=ir)
995 @@ -257,7 +257,7 @@ class IdlCompiler(object):
997 self._ir_map.move_to_new_phase()
999 - map(process_interface_like, old_irs)
1000 + list(map(process_interface_like, old_irs))
1002 def _determine_blink_headers(self):
1003 irs = self._ir_map.irs_of_kinds(
1004 @@ -422,9 +422,9 @@ class IdlCompiler(object):
1005 assert not new_interface.deriveds
1006 derived_set = identifier_to_derived_set.get(
1007 new_interface.identifier, set())
1008 - new_interface.deriveds = map(
1009 - lambda id_: self._ref_to_idl_def_factory.create(id_),
1010 - sorted(derived_set))
1011 + new_interface.deriveds = list(
1012 + map(lambda id_: self._ref_to_idl_def_factory.create(id_),
1013 + sorted(derived_set)))
1015 def _supplement_missing_html_constructor_operation(self):
1016 # Temporary mitigation of misuse of [HTMLConstructor]
1017 @@ -553,7 +553,8 @@ class IdlCompiler(object):
1018 self._ir_map.add(new_ir)
1020 for group in new_ir.iter_all_overload_groups():
1021 - exposures = map(lambda overload: overload.exposure, group)
1022 + exposures = list(map(lambda overload: overload.exposure,
1023 + group))
1025 # [Exposed]
1026 if any(not exposure.global_names_and_features
1027 @@ -653,8 +654,8 @@ class IdlCompiler(object):
1028 constructs = set()
1029 for global_name in global_names:
1030 constructs.update(exposed_map.get(global_name, []))
1031 - new_ir.exposed_constructs = map(
1032 - self._ref_to_idl_def_factory.create, sorted(constructs))
1033 + new_ir.exposed_constructs = list(
1034 + map(self._ref_to_idl_def_factory.create, sorted(constructs)))
1036 assert not new_ir.legacy_window_aliases
1037 if new_ir.identifier != 'Window':
1038 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py
1039 index 65d24e529d1..067ef2eb0b2 100644
1040 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py
1041 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py
1042 @@ -180,8 +180,9 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
1043 self._constructor_groups = tuple([
1044 ConstructorGroup(
1045 group_ir,
1046 - filter(lambda x: x.identifier == group_ir.identifier,
1047 - self._constructors),
1048 + list(
1049 + filter(lambda x: x.identifier == group_ir.identifier,
1050 + self._constructors)),
1051 owner=self) for group_ir in ir.constructor_groups
1053 assert len(self._constructor_groups) <= 1
1054 @@ -192,8 +193,9 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
1055 self._named_constructor_groups = tuple([
1056 ConstructorGroup(
1057 group_ir,
1058 - filter(lambda x: x.identifier == group_ir.identifier,
1059 - self._named_constructors),
1060 + list(
1061 + filter(lambda x: x.identifier == group_ir.identifier,
1062 + self._named_constructors)),
1063 owner=self) for group_ir in ir.named_constructor_groups
1065 self._operations = tuple([
1066 @@ -203,22 +205,23 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
1067 self._operation_groups = tuple([
1068 OperationGroup(
1069 group_ir,
1070 - filter(lambda x: x.identifier == group_ir.identifier,
1071 - self._operations),
1072 + list(
1073 + filter(lambda x: x.identifier == group_ir.identifier,
1074 + self._operations)),
1075 owner=self) for group_ir in ir.operation_groups
1077 self._exposed_constructs = tuple(ir.exposed_constructs)
1078 self._legacy_window_aliases = tuple(ir.legacy_window_aliases)
1079 self._indexed_and_named_properties = None
1080 - indexed_and_named_property_operations = filter(
1081 - lambda x: x.is_indexed_or_named_property_operation,
1082 - self._operations)
1083 + indexed_and_named_property_operations = list(
1084 + filter(lambda x: x.is_indexed_or_named_property_operation,
1085 + self._operations))
1086 if indexed_and_named_property_operations:
1087 self._indexed_and_named_properties = IndexedAndNamedProperties(
1088 indexed_and_named_property_operations, owner=self)
1089 self._stringifier = None
1090 - stringifier_operation_irs = filter(lambda x: x.is_stringifier,
1091 - ir.operations)
1092 + stringifier_operation_irs = list(
1093 + filter(lambda x: x.is_stringifier, ir.operations))
1094 if stringifier_operation_irs:
1095 assert len(stringifier_operation_irs) == 1
1096 op_ir = make_copy(stringifier_operation_irs[0])
1097 @@ -231,8 +234,9 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
1098 attribute = None
1099 if operation.stringifier_attribute:
1100 attr_id = operation.stringifier_attribute
1101 - attributes = filter(lambda x: x.identifier == attr_id,
1102 - self._attributes)
1103 + attributes = list(
1104 + filter(lambda x: x.identifier == attr_id,
1105 + self._attributes))
1106 assert len(attributes) == 1
1107 attribute = attributes[0]
1108 self._stringifier = Stringifier(operation, attribute, owner=self)
1109 @@ -578,8 +582,9 @@ class Iterable(WithDebugInfo):
1110 self._operation_groups = tuple([
1111 OperationGroup(
1112 group_ir,
1113 - filter(lambda x: x.identifier == group_ir.identifier,
1114 - self._operations),
1115 + list(
1116 + filter(lambda x: x.identifier == group_ir.identifier,
1117 + self._operations)),
1118 owner=owner) for group_ir in ir.operation_groups
1121 @@ -666,8 +671,9 @@ class Maplike(WithDebugInfo):
1122 self._operation_groups = tuple([
1123 OperationGroup(
1124 group_ir,
1125 - filter(lambda x: x.identifier == group_ir.identifier,
1126 - self._operations),
1127 + list(
1128 + filter(lambda x: x.identifier == group_ir.identifier,
1129 + self._operations)),
1130 owner=owner) for group_ir in ir.operation_groups
1133 @@ -755,8 +761,9 @@ class Setlike(WithDebugInfo):
1134 self._operation_groups = tuple([
1135 OperationGroup(
1136 group_ir,
1137 - filter(lambda x: x.identifier == group_ir.identifier,
1138 - self._operations),
1139 + list(
1140 + filter(lambda x: x.identifier == group_ir.identifier,
1141 + self._operations)),
1142 owner=owner) for group_ir in ir.operation_groups
1145 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py
1146 index e9aeff4ab82..d80554d603e 100644
1147 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py
1148 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py
1149 @@ -2,6 +2,8 @@
1150 # Use of this source code is governed by a BSD-style license that can be
1151 # found in the LICENSE file.
1153 +import sys
1155 from .argument import Argument
1156 from .ast_group import AstGroup
1157 from .attribute import Attribute
1158 @@ -30,6 +32,11 @@ from .operation import Operation
1159 from .typedef import Typedef
1162 +# TODO: Remove this once Python2 is obsoleted.
1163 +if sys.version_info.major != 2:
1164 + long = int
1167 def load_and_register_idl_definitions(filepaths, register_ir,
1168 create_ref_to_idl_def, idl_type_factory):
1170 @@ -160,7 +167,7 @@ class _IRBuilder(object):
1171 child_nodes = list(node.GetChildren())
1172 extended_attributes = self._take_extended_attributes(child_nodes)
1174 - members = map(self._build_interface_member, child_nodes)
1175 + members = list(map(self._build_interface_member, child_nodes))
1176 attributes = []
1177 constants = []
1178 operations = []
1179 @@ -302,7 +309,7 @@ class _IRBuilder(object):
1180 child_nodes = list(node.GetChildren())
1181 inherited = self._take_inheritance(child_nodes)
1182 extended_attributes = self._take_extended_attributes(child_nodes)
1183 - own_members = map(self._build_dictionary_member, child_nodes)
1184 + own_members = list(map(self._build_dictionary_member, child_nodes))
1186 return Dictionary.IR(
1187 identifier=Identifier(node.GetName()),
1188 @@ -336,7 +343,7 @@ class _IRBuilder(object):
1190 child_nodes = list(node.GetChildren())
1191 extended_attributes = self._take_extended_attributes(child_nodes)
1192 - members = map(self._build_interface_member, child_nodes)
1193 + members = list(map(self._build_interface_member, child_nodes))
1194 constants = []
1195 operations = []
1196 for member in members:
1197 @@ -456,8 +463,8 @@ class _IRBuilder(object):
1198 assert len(child_nodes) == 1
1199 child = child_nodes[0]
1200 if child.GetClass() == 'Arguments':
1201 - arguments = map(build_extattr_argument,
1202 - child.GetChildren())
1203 + arguments = list(
1204 + map(build_extattr_argument, child.GetChildren()))
1205 elif child.GetClass() == 'Call':
1206 assert len(child.GetChildren()) == 1
1207 grand_child = child.GetChildren()[0]
1208 @@ -486,7 +493,9 @@ class _IRBuilder(object):
1210 assert node.GetClass() == 'ExtAttributes'
1211 return ExtendedAttributes(
1212 - filter(None, map(build_extended_attribute, node.GetChildren())))
1213 + list(
1214 + filter(None, map(build_extended_attribute,
1215 + node.GetChildren()))))
1217 def _build_inheritance(self, node):
1218 assert node.GetClass() == 'Inherit'
1219 @@ -506,7 +515,7 @@ class _IRBuilder(object):
1221 def _build_iterable(self, node):
1222 assert node.GetClass() == 'Iterable'
1223 - types = map(self._build_type, node.GetChildren())
1224 + types = list(map(self._build_type, node.GetChildren()))
1225 assert len(types) == 1 or len(types) == 2
1226 if len(types) == 1: # value iterator
1227 key_type, value_type = (None, types[0])
1228 @@ -584,7 +593,7 @@ class _IRBuilder(object):
1229 def _build_maplike(self, node, interface_identifier):
1230 assert node.GetClass() == 'Maplike'
1231 assert isinstance(interface_identifier, Identifier)
1232 - types = map(self._build_type, node.GetChildren())
1233 + types = list(map(self._build_type, node.GetChildren()))
1234 assert len(types) == 2
1235 key_type, value_type = types
1236 is_readonly = bool(node.GetProperty('READONLY'))
1237 @@ -676,7 +685,7 @@ class _IRBuilder(object):
1238 def _build_setlike(self, node, interface_identifier):
1239 assert node.GetClass() == 'Setlike'
1240 assert isinstance(interface_identifier, Identifier)
1241 - types = map(self._build_type, node.GetChildren())
1242 + types = list(map(self._build_type, node.GetChildren()))
1243 assert len(types) == 1
1244 value_type = types[0]
1245 is_readonly = bool(node.GetProperty('READONLY'))
1246 @@ -838,7 +847,7 @@ class _IRBuilder(object):
1248 def build_union_type(node, extended_attributes):
1249 return self._idl_type_factory.union_type(
1250 - member_types=map(self._build_type, node.GetChildren()),
1251 + member_types=list(map(self._build_type, node.GetChildren())),
1252 is_optional=is_optional,
1253 extended_attributes=extended_attributes,
1254 debug_info=self._build_debug_info(node))
1255 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py
1256 index a7a2b11f3f0..2f6b61300ff 100644
1257 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py
1258 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py
1259 @@ -3,6 +3,13 @@
1260 # found in the LICENSE file.
1263 +import sys
1265 +# TODO: Remove this once Python2 is obsoleted.
1266 +if sys.version_info.major != 2:
1267 + long = int
1268 + basestring = str
1270 def make_copy(obj, memo=None):
1272 Creates a copy of the given object, which should be an IR or part of IR.
1273 diff --git a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py
1274 index eeabef97cbe..bd7e98907f3 100644
1275 --- a/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py
1276 +++ b/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py
1277 @@ -107,11 +107,13 @@ class Namespace(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
1278 for operation_ir in ir.operations
1280 self._operation_groups = tuple([
1281 - OperationGroup(
1282 - operation_group_ir,
1283 - filter(lambda x: x.identifier == operation_group_ir.identifier,
1284 - self._operations),
1285 - owner=self) for operation_group_ir in ir.operation_groups
1286 + OperationGroup(operation_group_ir,
1287 + list(
1288 + filter(
1289 + lambda x: x.identifier == operation_group_ir
1290 + .identifier, self._operations)),
1291 + owner=self)
1292 + for operation_group_ir in ir.operation_groups
1295 @property
1296 diff --git a/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl b/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl
1297 index 0add9c45a38..dc910f6d227 100644
1298 --- a/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl
1299 +++ b/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl
1300 @@ -59,9 +59,9 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8_value, {
1301 DCHECK(executionContext);
1302 {% endif %}{# has_origin_trial_members #}
1303 {% endif %}{# members #}
1304 - {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %}
1305 + {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %}
1306 {% filter origin_trial_enabled(origin_trial_test, "executionContext") %}
1307 - {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %}
1308 + {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %}
1309 {% filter runtime_enabled(feature_name) %}
1310 {% for member in member_list %}
1311 v8::Local<v8::Value> {{member.v8_value}};
1312 @@ -147,9 +147,9 @@ bool toV8{{cpp_class}}(const {{cpp_class}}* impl, v8::Local<v8::Object> dictiona
1313 DCHECK(executionContext);
1314 {% endif %}{# has_origin_trial_members #}
1315 {% endif %}{# members #}
1316 - {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %}
1317 + {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %}
1318 {% filter origin_trial_enabled(origin_trial_test, "executionContext") %}
1319 - {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %}
1320 + {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %}
1321 {% filter runtime_enabled(feature_name) %}
1322 {% for member in member_list %}
1323 v8::Local<v8::Value> {{member.v8_value}};
1324 diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py
1325 index 1799cd5a153..5f43ffabc26 100755
1326 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py
1327 +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py
1328 @@ -71,7 +71,7 @@ class Expansion(object):
1329 def enabled_longhands(self):
1330 include = lambda longhand: not longhand[
1331 'runtime_flag'] or self.is_enabled(longhand['runtime_flag'])
1332 - return filter(include, self._longhands)
1333 + return list(filter(include, self._longhands))
1335 @property
1336 def index(self):
1337 @@ -87,8 +87,9 @@ class Expansion(object):
1339 def create_expansions(longhands):
1340 flags = collect_runtime_flags(longhands)
1341 - expansions = map(lambda mask: Expansion(longhands, flags, mask),
1342 - range(1 << len(flags)))
1343 + expansions = list(
1344 + map(lambda mask: Expansion(longhands, flags, mask),
1345 + range(1 << len(flags))))
1346 assert len(expansions) > 0
1347 # We generate 2^N expansions for N flags, so enforce some limit.
1348 assert len(flags) <= 4, 'Too many runtime flags for a single shorthand'
1349 @@ -114,14 +115,14 @@ class StylePropertyShorthandWriter(json5_generator.Writer):
1351 self._longhand_dictionary = defaultdict(list)
1352 for property_ in json5_properties.shorthands:
1353 - property_['longhand_enum_keys'] = map(enum_key_for_css_property,
1354 - property_['longhands'])
1355 - property_['longhand_property_ids'] = map(id_for_css_property,
1356 - property_['longhands'])
1358 - longhands = map(
1359 - lambda name: json5_properties.properties_by_name[name],
1360 - property_['longhands'])
1361 + property_['longhand_enum_keys'] = list(
1362 + map(enum_key_for_css_property, property_['longhands']))
1363 + property_['longhand_property_ids'] = list(
1364 + map(id_for_css_property, property_['longhands']))
1366 + longhands = list(
1367 + map(lambda name: json5_properties.properties_by_name[name],
1368 + property_['longhands']))
1369 property_['expansions'] = create_expansions(longhands)
1370 for longhand_enum_key in property_['longhand_enum_keys']:
1371 self._longhand_dictionary[longhand_enum_key].append(property_)
1372 diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
1373 index 75030ac577e..f72aadee17d 100755
1374 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
1375 +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
1376 @@ -42,8 +42,8 @@ class CSSPropertyInstancesWriter(json5_generator.Writer):
1377 aliases = self._css_properties.aliases
1379 # Lists of PropertyClassData.
1380 - self._property_classes_by_id = map(self.get_class, properties)
1381 - self._alias_classes_by_id = map(self.get_class, aliases)
1382 + self._property_classes_by_id = list(map(self.get_class, properties))
1383 + self._alias_classes_by_id = list(map(self.get_class, aliases))
1385 # Sort by enum value.
1386 self._property_classes_by_id.sort(key=lambda t: t.enum_value)
1387 diff --git a/chromium/third_party/blink/renderer/build/scripts/gperf.py b/chromium/third_party/blink/renderer/build/scripts/gperf.py
1388 index 5ee49056be4..db72660d471 100644
1389 --- a/chromium/third_party/blink/renderer/build/scripts/gperf.py
1390 +++ b/chromium/third_party/blink/renderer/build/scripts/gperf.py
1391 @@ -95,7 +95,7 @@ def main():
1393 open(args.output_file, 'wb').write(
1394 generate_gperf(gperf_path,
1395 - open(infile).read(), gperf_args))
1396 + open(infile).read(), gperf_args).encode('utf-8'))
1399 if __name__ == '__main__':
1400 diff --git a/chromium/third_party/blink/renderer/build/scripts/in_file.py b/chromium/third_party/blink/renderer/build/scripts/in_file.py
1401 index 28adc050f1e..58113483e57 100644
1402 --- a/chromium/third_party/blink/renderer/build/scripts/in_file.py
1403 +++ b/chromium/third_party/blink/renderer/build/scripts/in_file.py
1404 @@ -66,7 +66,7 @@ class InFile(object):
1405 self._defaults = defaults
1406 self._valid_values = copy.deepcopy(
1407 valid_values if valid_values else {})
1408 - self._parse(map(str.strip, lines))
1409 + self._parse(list(map(str.strip, lines)))
1411 @classmethod
1412 def load_from_files(self, file_paths, defaults, valid_values,
1413 diff --git a/chromium/third_party/blink/renderer/build/scripts/in_generator.py b/chromium/third_party/blink/renderer/build/scripts/in_generator.py
1414 index e46740a2e85..ab1981ad1e3 100644
1415 --- a/chromium/third_party/blink/renderer/build/scripts/in_generator.py
1416 +++ b/chromium/third_party/blink/renderer/build/scripts/in_generator.py
1417 @@ -32,10 +32,15 @@ import os
1418 import os.path
1419 import shlex
1420 import shutil
1421 +import sys
1422 import optparse
1424 from in_file import InFile
1426 +# TODO: Remove this once Python2 is obsoleted.
1427 +if sys.version_info.major != 2:
1428 + basestring = str
1431 #########################################################
1432 # This is now deprecated - use json5_generator.py instead
1433 diff --git a/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py b/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py
1434 index cafe8d94a8e..6925a4fa580 100755
1435 --- a/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py
1436 +++ b/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py
1437 @@ -138,7 +138,7 @@ class RuntimeFeatureWriter(BaseRuntimeFeatureWriter):
1438 except Exception:
1439 # If trouble unpickling, overwrite
1440 pass
1441 - with open(os.path.abspath(file_name), 'w') as pickle_file:
1442 + with open(os.path.abspath(file_name), 'wb') as pickle_file:
1443 pickle.dump(features_map, pickle_file)
1445 def _template_inputs(self):
1446 diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl
1447 index dc3f44c5b10..3eefcf9f0ee 100644
1448 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl
1449 +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl
1450 @@ -26,7 +26,7 @@ using {{namespace}}FunctionMap = HashMap<AtomicString, {{namespace}}ConstructorF
1452 static {{namespace}}FunctionMap* g_{{namespace|lower}}_constructors = nullptr;
1454 -{% for tag in tags|sort if not tag.noConstructor %}
1455 +{% for tag in tags|sort(attribute='name') if not tag.noConstructor %}
1456 static {{namespace}}Element* {{namespace}}{{tag.name.to_upper_camel_case()}}Constructor(
1457 Document& document, const CreateElementFlags flags) {
1458 {% if tag.runtimeEnabled %}
1459 @@ -52,7 +52,7 @@ static void Create{{namespace}}FunctionMap() {
1460 // Empty array initializer lists are illegal [dcl.init.aggr] and will not
1461 // compile in MSVC. If tags list is empty, add check to skip this.
1462 static const Create{{namespace}}FunctionMapData data[] = {
1463 - {% for tag in tags|sort if not tag.noConstructor %}
1464 + {% for tag in tags|sort(attribute='name') if not tag.noConstructor %}
1465 { {{cpp_namespace}}::{{tag|symbol}}Tag, {{namespace}}{{tag.name.to_upper_camel_case()}}Constructor },
1466 {% endfor %}
1468 diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl
1469 index 9bfc489e048..5f86184e879 100644
1470 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl
1471 +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl
1472 @@ -22,7 +22,7 @@ HTMLTypeMap CreateHTMLTypeMap() {
1473 const char* name;
1474 HTMLElementType type;
1475 } kTags[] = {
1476 - {% for tag in tags|sort %}
1477 + {% for tag in tags|sort(attribute='name') %}
1478 { "{{tag.name}}", HTMLElementType::k{{tag.js_interface}} },
1479 {% endfor %}
1481 @@ -42,7 +42,7 @@ HTMLElementType htmlElementTypeForTag(const AtomicString& tagName, const Documen
1482 if (it == html_type_map.end())
1483 return HTMLElementType::kHTMLUnknownElement;
1485 - {% for tag in tags|sort %}
1486 + {% for tag in tags|sort(attribute='name') %}
1487 {% if tag.runtimeEnabled %}
1488 if (tagName == "{{tag.name}}") {
1489 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(document->GetExecutionContext())) {
1490 diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl
1491 index 1b5297d52dc..edecc81d9d4 100644
1492 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl
1493 +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl
1494 @@ -15,7 +15,7 @@ namespace blink {
1495 class Document;
1497 // Type checking.
1498 -{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
1499 +{% for tag in tags|sort(attribute='name') if not tag.multipleTagNames and not tag.noTypeHelpers %}
1500 class {{tag.interface}};
1501 template <>
1502 inline bool IsElementOfType<const {{tag.interface}}>(const Node& node) {
1503 diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl
1504 index 0244433af2e..dcdbb02a56c 100644
1505 --- a/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl
1506 +++ b/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl
1507 @@ -25,7 +25,7 @@
1510 {% macro trie_leaf(index, object, return_macro, lowercase_data) %}
1511 -{% set name, value = object.items()[0] %}
1512 +{% set name, value = (object.items()|list)[0] %}
1513 {% if name|length %}
1514 if (
1515 {%- for c in name -%}
1516 @@ -45,7 +45,7 @@ return {{ return_macro(value) }};
1519 {% macro trie_switch(trie, index, return_macro, lowercase_data) %}
1520 -{% if trie|length == 1 and trie.values()[0] is string %}
1521 +{% if trie|length == 1 and (trie.values()|list)[0] is string %}
1522 {{ trie_leaf(index, trie, return_macro, lowercase_data) -}}
1523 {% else %}
1524 {% if lowercase_data %}
1525 diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl
1526 index cb05c6c4315..bd5566b03e7 100644
1527 --- a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl
1528 +++ b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl
1529 @@ -24,12 +24,12 @@ namespace {{cpp_namespace}} {
1530 {{symbol_export}}extern const WTF::AtomicString& {{namespace_prefix}}NamespaceURI;
1532 // Tags
1533 -{% for tag in tags|sort %}
1534 +{% for tag in tags|sort(attribute='name') %}
1535 {{symbol_export}}extern const blink::{{namespace}}QualifiedName& {{tag|symbol}}Tag;
1536 {% endfor %}
1538 // Attributes
1539 -{% for attr in attrs|sort %}
1540 +{% for attr in attrs|sort(attribute='name') %}
1541 {{symbol_export}}extern const blink::QualifiedName& {{attr|symbol}}Attr;
1542 {% endfor %}
1544 diff --git a/chromium/third_party/dawn/generator/generator_lib.py b/chromium/third_party/dawn/generator/generator_lib.py
1545 index 5e3734d7833..e3d46bd194f 100644
1546 --- a/chromium/third_party/dawn/generator/generator_lib.py
1547 +++ b/chromium/third_party/dawn/generator/generator_lib.py
1548 @@ -201,6 +201,10 @@ def _compute_python_dependencies(root_dir=None):
1550 paths = set()
1551 for path in module_paths:
1552 + # Builtin/namespaced modules may return None for the file path.
1553 + if not path:
1554 + continue
1556 path = os.path.abspath(path)
1558 if not path.startswith(root_dir):
1559 diff --git a/chromium/third_party/devtools-frontend/src/BUILD.gn b/chromium/third_party/devtools-frontend/src/BUILD.gn
1560 index cd488e88b60..ea1dc3d9a79 100644
1561 --- a/chromium/third_party/devtools-frontend/src/BUILD.gn
1562 +++ b/chromium/third_party/devtools-frontend/src/BUILD.gn
1563 @@ -2,6 +2,8 @@
1564 # Use of this source code is governed by a BSD-style license that can be
1565 # found in the LICENSE file.
1567 +import("//build/config/python.gni")
1569 import("//third_party/blink/public/public_features.gni")
1570 import("./all_devtools_files.gni")
1571 import("./all_devtools_modules.gni")
1572 diff --git a/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py b/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py
1573 index d6666e8b74f..0f7a661e632 100644
1574 --- a/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py
1575 +++ b/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py
1576 @@ -45,7 +45,8 @@ def rollup(input_path, output_path, filename, max_size, rollup_plugin):
1577 ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] +
1578 ['--plugin', rollup_plugin],
1579 stdout=subprocess.PIPE,
1580 - stderr=subprocess.PIPE)
1581 + stderr=subprocess.PIPE,
1582 + text=True)
1583 out, error = rollup_process.communicate()
1584 if not out:
1585 raise Exception("rollup failed: " + error)
1586 diff --git a/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py b/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py
1587 index fa8e73d34af..7d0b84b2171 100644
1588 --- a/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py
1589 +++ b/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py
1590 @@ -10,7 +10,7 @@ Builds applications in release mode:
1591 and the application loader into a single script.
1594 -from cStringIO import StringIO
1595 +from io import StringIO
1596 from os import path
1597 from os.path import join
1598 import copy
1599 @@ -145,8 +145,7 @@ class ReleaseBuilder(object):
1600 resource_content = read_file(path.join(self.application_dir, resource_name))
1601 if not (resource_name.endswith('.html')
1602 or resource_name.endswith('md')):
1603 - resource_content += resource_source_url(resource_name).encode(
1604 - 'utf-8')
1605 + resource_content += resource_source_url(resource_name)
1606 resource_content = resource_content.replace('\\', '\\\\')
1607 resource_content = resource_content.replace('\n', '\\n')
1608 resource_content = resource_content.replace('"', '\\"')
1609 @@ -173,7 +172,9 @@ class ReleaseBuilder(object):
1610 def _concatenate_application_script(self, output):
1611 output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
1612 if self.descriptors.extends:
1613 - output.write('Root.applicationDescriptor.modules.push(...%s);' % json.dumps(self.descriptors.application.values()))
1614 + output.write(
1615 + 'Root.applicationDescriptor.modules.push(...%s);' %
1616 + json.dumps(list(self.descriptors.application.values())))
1617 else:
1618 output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json())
1620 diff --git a/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py b/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py
1621 index be510c48d76..c6a59c90298 100644
1622 --- a/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py
1623 +++ b/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py
1624 @@ -123,7 +123,7 @@ def main(argv):
1626 try:
1627 os.makedirs(path.join(output_directory, 'Images'))
1628 - except OSError, e:
1629 + except OSError as e:
1630 if e.errno != errno.EEXIST:
1631 raise e
1633 @@ -147,7 +147,7 @@ def main(argv):
1634 shutil.copy(path.join(dirname, filename), path.join(output_directory, 'Images'))
1635 add_file_to_grd(doc, path.join('Images', filename))
1637 - with open(parsed_args.output_filename, 'w') as output_file:
1638 + with open(parsed_args.output_filename, 'wb') as output_file:
1639 output_file.write(doc.toxml(encoding='UTF-8'))
1642 diff --git a/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py b/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py
1643 index 0ba695d3810..bb1da2f9f8d 100644
1644 --- a/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py
1645 +++ b/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py
1646 @@ -7,6 +7,8 @@
1647 Utilities for the modular DevTools build.
1650 +from __future__ import print_function
1652 import collections
1653 from os import path
1654 import os
1655 @@ -40,7 +42,7 @@ def load_and_parse_json(filename):
1656 try:
1657 return json.loads(read_file(filename))
1658 except:
1659 - print 'ERROR: Failed to parse %s' % filename
1660 + print('ERROR: Failed to parse %s' % filename)
1661 raise
1663 class Descriptors:
1664 @@ -57,7 +59,7 @@ class Descriptors:
1666 def application_json(self):
1667 result = dict()
1668 - result['modules'] = self.application.values()
1669 + result['modules'] = list(self.application.values())
1670 return json.dumps(result)
1672 def all_compiled_files(self):
1673 diff --git a/chromium/third_party/jinja2/tests.py b/chromium/third_party/jinja2/tests.py
1674 index 0adc3d4dbcb..b14f85ff148 100644
1675 --- a/chromium/third_party/jinja2/tests.py
1676 +++ b/chromium/third_party/jinja2/tests.py
1677 @@ -10,7 +10,7 @@
1679 import operator
1680 import re
1681 -from collections import Mapping
1682 +from collections.abc import Mapping
1683 from jinja2.runtime import Undefined
1684 from jinja2._compat import text_type, string_types, integer_types
1685 import decimal
1686 diff --git a/chromium/tools/metrics/ukm/gen_builders.py b/chromium/tools/metrics/ukm/gen_builders.py
1687 index f9f61d90a56..44e46fae8cc 100755
1688 --- a/chromium/tools/metrics/ukm/gen_builders.py
1689 +++ b/chromium/tools/metrics/ukm/gen_builders.py
1690 @@ -48,9 +48,10 @@ def ReadFilteredData(path):
1691 data = ukm_model.UKM_XML_TYPE.Parse(ukm_file.read())
1692 event_tag = ukm_model._EVENT_TYPE.tag
1693 metric_tag = ukm_model._METRIC_TYPE.tag
1694 - data[event_tag] = filter(ukm_model.IsNotObsolete, data[event_tag])
1695 + data[event_tag] = list(filter(ukm_model.IsNotObsolete, data[event_tag]))
1696 for event in data[event_tag]:
1697 - event[metric_tag] = filter(ukm_model.IsNotObsolete, event[metric_tag])
1698 + event[metric_tag] = list(
1699 + filter(ukm_model.IsNotObsolete, event[metric_tag]))
1700 return data
1703 diff --git a/chromium/ui/ozone/generate_constructor_list.py b/chromium/ui/ozone/generate_constructor_list.py
1704 index 8d800636c97..04fa18e93df 100755
1705 --- a/chromium/ui/ozone/generate_constructor_list.py
1706 +++ b/chromium/ui/ozone/generate_constructor_list.py
1707 @@ -45,12 +45,15 @@ Example Output: ./ui/ozone/generate_constructor_list.py \
1708 } // namespace ui
1711 +try:
1712 + from StringIO import StringIO # for Python 2
1713 +except ImportError:
1714 + from io import StringIO # for Python 3
1715 import optparse
1716 import os
1717 import collections
1718 import re
1719 import sys
1720 -import string
1723 def GetTypedefName(typename):
1724 @@ -68,7 +71,7 @@ def GetConstructorName(typename, platform):
1725 This is just "Create" + typename + platform.
1728 - return 'Create' + typename + string.capitalize(platform)
1729 + return 'Create' + typename + platform.capitalize()
1732 def GenerateConstructorList(out, namespace, export, typenames, platforms,
1733 @@ -163,12 +166,14 @@ def main(argv):
1734 sys.exit(1)
1736 # Write to standard output or file specified by --output_cc.
1737 - out_cc = sys.stdout
1738 + out_cc = getattr(sys.stdout, 'buffer', sys.stdout)
1739 if options.output_cc:
1740 out_cc = open(options.output_cc, 'wb')
1742 - GenerateConstructorList(out_cc, options.namespace, options.export,
1743 + out_cc_str = StringIO()
1744 + GenerateConstructorList(out_cc_str, options.namespace, options.export,
1745 typenames, platforms, includes, usings)
1746 + out_cc.write(out_cc_str.getvalue().encode('utf-8'))
1748 if options.output_cc:
1749 out_cc.close()
1750 diff --git a/chromium/ui/ozone/generate_ozone_platform_list.py b/chromium/ui/ozone/generate_ozone_platform_list.py
1751 index d47c398259b..2702b68b9bd 100755
1752 --- a/chromium/ui/ozone/generate_ozone_platform_list.py
1753 +++ b/chromium/ui/ozone/generate_ozone_platform_list.py
1754 @@ -49,12 +49,15 @@ Example Output: ./generate_ozone_platform_list.py --default wayland dri wayland
1758 +try:
1759 + from StringIO import StringIO # for Python 2
1760 +except ImportError:
1761 + from io import StringIO # for Python 3
1762 import optparse
1763 import os
1764 import collections
1765 import re
1766 import sys
1767 -import string
1770 def GetConstantName(name):
1771 @@ -63,7 +66,7 @@ def GetConstantName(name):
1772 We just capitalize the platform name and prepend "CreateOzonePlatform".
1775 - return 'kPlatform' + string.capitalize(name)
1776 + return 'kPlatform' + name.capitalize()
1779 def GeneratePlatformListText(out, platforms):
1780 @@ -149,9 +152,9 @@ def main(argv):
1781 platforms.insert(0, options.default)
1783 # Write to standard output or file specified by --output_{cc,h}.
1784 - out_cc = sys.stdout
1785 - out_h = sys.stdout
1786 - out_txt = sys.stdout
1787 + out_cc = getattr(sys.stdout, 'buffer', sys.stdout)
1788 + out_h = getattr(sys.stdout, 'buffer', sys.stdout)
1789 + out_txt = getattr(sys.stdout, 'buffer', sys.stdout)
1790 if options.output_cc:
1791 out_cc = open(options.output_cc, 'wb')
1792 if options.output_h:
1793 @@ -159,9 +162,16 @@ def main(argv):
1794 if options.output_txt:
1795 out_txt = open(options.output_txt, 'wb')
1797 - GeneratePlatformListText(out_txt, platforms)
1798 - GeneratePlatformListHeader(out_h, platforms)
1799 - GeneratePlatformListSource(out_cc, platforms)
1800 + out_txt_str = StringIO()
1801 + out_h_str = StringIO()
1802 + out_cc_str = StringIO()
1804 + GeneratePlatformListText(out_txt_str, platforms)
1805 + out_txt.write(out_txt_str.getvalue().encode('utf-8'))
1806 + GeneratePlatformListHeader(out_h_str, platforms)
1807 + out_h.write(out_h_str.getvalue().encode('utf-8'))
1808 + GeneratePlatformListSource(out_cc_str, platforms)
1809 + out_cc.write(out_cc_str.getvalue().encode('utf-8'))
1811 if options.output_cc:
1812 out_cc.close()