[PATCH v2 1/1] travis-ci: Fix "ResourceWarning: unclosed file"

Stephen Warren swarren at wwwdotorg.org
Mon Dec 30 17:41:58 CET 2019


On 12/30/19 4:49 AM, Cristian Ciocaltea wrote:
> 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 at gmail.com>
> ---
> Changes in v2:
> * The warning line number in the comment relies on Heinrich Schuchardt's
>    work 'travis-ci: provide env__efi_fit_tftp_file', but my initial patch
>    was based on the master version. Even though it is still applicable,
>    to avoid any confusion, I rebased it on Heinrich's latest patch (v2):
>    
>    https://lists.denx.de/pipermail/u-boot/2019-December/395029.html

There's no need to rebase the patch for that kind of thing; the warning 
is only a reference/example anyway, and the next time someone edits this 
file after you, the line number will change again, and we can't go back 
and edit this commit description to patch that up.

> diff --git a/py/travis-ci/travis_tftp.py b/py/travis-ci/travis_tftp.py

> +
> +    with open(file_full, 'rb') as fd:
> +        ret["crc32"] = hex(binascii.crc32(fd.read()) & 0xffffffff)[2:]

Nit: "f" for "file" rather than "fd" for "file descriptor" (usually an 
integer) would have been a better variable name. No need to resend to 
change this though.

Reviewed-by: Stephen Warren <swarren at nvidia.com>


More information about the U-Boot mailing list