From 94ed4c384c3425963b459a735045706e5f83f01b Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 5 Mar 2020 21:07:10 +0200 Subject: [PATCH] generate_vulkan_layers_json.py: Fix Python 3 compatibility json.dump() returns a string. Writing strings to a file opened in binary mode doesn't work. Python 2 doesn't properly distringuish bytes and strings. Open in non-binary mode, so this code works on both. Traceback (most recent call last): File "../../third_party/angle/third_party/vulkan-tools/src/build-gn/generate_vulkan_layers_json.py", line 126, in sys.exit(main()) File "../../third_party/angle/third_party/vulkan-tools/src/build-gn/generate_vulkan_layers_json.py", line 83, in main json.dump(data, outfile) File "C:\Program Files\Python38\lib\json\__init__.py", line 180, in dump fp.write(chunk) TypeError: a bytes-like object is required, not 'str' Chromium bug: https://crbug.com/941669 --- build-gn/generate_vulkan_layers_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-gn/generate_vulkan_layers_json.py b/build-gn/generate_vulkan_layers_json.py index 2999cd8..2e2b3d5 100755 --- a/build-gn/generate_vulkan_layers_json.py +++ b/build-gn/generate_vulkan_layers_json.py @@ -79,7 +79,7 @@ def main(): data[data_key]['library_path'] = prev_name target_fname = os.path.join(target_dir, os.path.basename(json_fname)) - with open(target_fname, 'wb') as outfile: + with open(target_fname, 'w') as outfile: json.dump(data, outfile) # Get the Vulkan version from the vulkan_core.h file -- 2.7.4