提交 04a47a57 authored 作者: Fei Zhan's avatar Fei Zhan 提交者: Frederic Bastien

close file with context manager

上级 a37a03f1
......@@ -568,4 +568,6 @@ def hash_from_file(file_path):
Return the MD5 hash of a file.
"""
return hash_from_code(open(file_path, 'rb').read())
with open(file_path, 'rb') as f:
file_content = f.read()
return hash_from_code(file_content)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论