Skip to content

Commit bc7cc34

Browse files
bnoordhuisBridgeAR
authored andcommitted
tools: python3 compat for inspector code generator
The code generator takes a dict and turns it into a namedtuple. The dict contains the key "async", which is a keyword in python 3.7, and rejected by the namedtuple constructor. Rename it to "async_" to avoid the clash. Fixes: #29326 PR-URL: #29340 Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 2dc52ad commit bc7cc34

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/inspector_protocol/code_generator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def json_object_hook(object_dict):
4141
items = [(k, os.path.join(output_base, v) if k == "path" else v) for (k, v) in object_dict.items()]
4242
items = [(k, os.path.join(output_base, v) if k == "output" else v) for (k, v) in items]
4343
keys, values = list(zip(*items))
44+
# 'async' is a python 3.7 keyword. Don't use namedtuple(rename=True)
45+
# because that only renames it in python 3 but not python 2.
46+
keys = tuple('async_' if k == 'async' else k for k in keys)
4447
return collections.namedtuple('X', keys)(*values)
4548
return json.loads(data, object_hook=json_object_hook)
4649

@@ -521,7 +524,7 @@ def generate_type(self, domain, typename):
521524
def is_async_command(self, domain, command):
522525
if not self.config.protocol.options:
523526
return False
524-
return self.check_options(self.config.protocol.options, domain, command, "async", None, False)
527+
return self.check_options(self.config.protocol.options, domain, command, "async_", None, False)
525528

526529

527530
def is_exported(self, domain, name):

0 commit comments

Comments
 (0)