提交 9cb9ff4d authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #5307 from nouiz/enfeizhan-master

close file with context manager
...@@ -568,4 +568,6 @@ def hash_from_file(file_path): ...@@ -568,4 +568,6 @@ def hash_from_file(file_path):
Return the MD5 hash of a file. 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论