From: Martin Schwan Date: Wed, 17 Dec 2025 13:06:44 +0000 (+0100) Subject: cargo-update-recipe-crates: Properly close target file after writing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ceb9f25ca7c9a1110a6953a8f7f1f88f17ed392;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git cargo-update-recipe-crates: Properly close target file after writing In do_update_crates(), properly close the target_file after writing to it using the "with" statement. Signed-off-by: Martin Schwan Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index ffc658f0f1..47e845c822 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -72,7 +72,8 @@ for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'): crates += c if crates is None: raise ValueError("Unable to find any Cargo.lock in ${CARGO_LOCK_SRC_DIR}") -open("${TARGET_FILE}", 'w').write(crates) +with open("${TARGET_FILE}", 'w') as f: + f.write(crates) EOF bbnote "Successfully update crates inside '${TARGET_FILE}'"