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