In do_update_crates(), properly close the target_file after writing to
it using the "with" statement.

Signed-off-by: Martin Schwan <[email protected]>
---
Changes in v2:
  - Split changes into multiple patches, for improved readability
---
 meta/classes-recipe/cargo-update-recipe-crates.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass 
b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
index 6e82bd4a51..6e933d3afc 100644
--- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
+++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
@@ -74,7 +74,8 @@ python do_update_crates() {
                     crates += c
     if crates is None:
         bb.error(f'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)
 
     bb.note(f'Successfully update crates inside \'{target_file}\'')
 }
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#227572): 
https://lists.openembedded.org/g/openembedded-core/message/227572
Mute This Topic: https://lists.openembedded.org/mt/116743594/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to