All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] travis-ci: Fix "ResourceWarning: unclosed file"
@ 2019-12-29 23:41 Cristian Ciocaltea
  0 siblings, 0 replies; only message in thread
From: Cristian Ciocaltea @ 2019-12-29 23:41 UTC (permalink / raw)
  To: u-boot

This patch gets rid of the warning messages like:

uboot-test-hooks/py/travis-ci/travis_tftp.py:43: ResourceWarning:
unclosed file <_io.BufferedReader name='.bm-work/qemu_arm/u-boot.bin'>

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@iquestgroup.com>
---
 py/travis-ci/travis_tftp.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/py/travis-ci/travis_tftp.py b/py/travis-ci/travis_tftp.py
index 4ea5c06..3e1f11d 100644
--- a/py/travis-ci/travis_tftp.py
+++ b/py/travis-ci/travis_tftp.py
@@ -20,8 +20,11 @@ def file2env(file_name, addr=None):
     ret = {
         "fn": file_name,
         "size": os.path.getsize(file_full),
-        "crc32": hex(binascii.crc32(open(file_full, 'rb').read()) & 0xffffffff)[2:],
     }
+
+    with open(file_full, 'rb') as fd:
+        ret["crc32"] = hex(binascii.crc32(fd.read()) & 0xffffffff)[2:]
+
     if addr is not None:
         ret['addr'] = addr
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-29 23:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-29 23:41 [PATCH v1 1/1] travis-ci: Fix "ResourceWarning: unclosed file" Cristian Ciocaltea

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.