vendor.py: stop loading Cargo.toml as toml
Currently, this script is breaking with `ValueError: Circular reference
detected` when dumping TOML in this case. Since we're never manipulating
this parsed TOML in the first place, it seems better to simply read and
write this as bytes.
BUG=b:240953811
TEST=./vendor.py from my chroot now works. Produces no changes.
Change-Id: Ib48af60316b02748330c00c714e7e477b9ac558b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/rust_crates/+/3822122
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com>
Commit-Queue: George Burgess <gbiv@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
diff --git a/vendor.py b/vendor.py
index 145b48e..eb3f3b3 100755
--- a/vendor.py
+++ b/vendor.py
@@ -521,8 +521,8 @@
# Also load the cargo.toml file which we need to write back
cargo_file = os.path.join(package_path, "Cargo.toml")
- with open(cargo_file, 'r') as cfile:
- cargo_contents = toml.load(cfile)
+ with open(cargo_file, 'rb') as cfile:
+ cargo_contents = cfile.read()
shutil.rmtree(package_path)
@@ -532,8 +532,8 @@
librs.write(self.LIB_RS_BODY)
# Restore cargo.toml
- with open(cargo_file, 'w') as cfile:
- toml.dump(cargo_contents, cfile)
+ with open(cargo_file, 'wb') as cfile:
+ cfile.write(cargo_contents)
# Restore checksum
with open(checksum_file, 'w') as csum: