提交 dfb1fd71 编写于 作者: L Lukáš Doktor

utils.archive: Properly close the opened file

On python3 this naked open reports ResourceWarning. Let's properly close
it:

    avocado/utils/archive.py:191: ResourceWarning: unclosed file
    <_io.TextIOWrapper name='/tmp/avocado___main__rv2ihor0/tmp0drzyrsb/
    link_to_file2' mode='r' encoding='UTF-8'>
      src = open(dst, 'r').read()
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 0d9c063c
......@@ -186,7 +186,8 @@ class ArchiveFile(object):
dst = os.path.join(dst_dir, path)
if not os.path.islink(dst):
# Link created as an ordinary file containing the dst path
src = open(dst, 'r').read()
with open(dst, 'r') as dst_path:
src = dst_path.read()
else:
# Link is already there and could be outdated. Let's read
# the original destination from the zip file.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册