Skip to content

Commit fa98a8b

Browse files
cclaussaduh95
authored andcommitted
tools: fix Python 3 issues in inspector_protocol
PR-URL: nodejs#29296 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent a0bae95 commit fa98a8b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tools/inspector_protocol/convert_protocol_to_json.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ def main(argv):
2121
parser.add_argument("json_file", help="The .json output file write.")
2222
args = parser.parse_args(argv)
2323
file_name = os.path.normpath(args.pdl_file)
24-
input_file = open(file_name, "r")
25-
pdl_string = input_file.read()
24+
with open(file_name, "r") as input_file:
25+
pdl_string = input_file.read()
2626
protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
27-
input_file.close()
2827

29-
output_file = open(os.path.normpath(args.json_file), 'wb')
30-
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
31-
output_file.close()
28+
with open(os.path.normpath(args.json_file), 'w') as output_file:
29+
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
3230

3331

3432
if __name__ == '__main__':

0 commit comments

Comments
 (0)