Skip to content

Commit

Permalink
encoding.read: fix ResourceWarning: unclosed file on some platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Nov 7, 2024
1 parent 24743b7 commit 5edd15e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion guidata/utils/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def read(filename: str, encoding: str = "utf-8") -> tuple[str, str]:
Read text from file ('filename')
Return text and encoding
"""
text, encoding = decode(open(filename, "rb").read())
with open(filename, "rb") as file:
text, encoding = decode(file.read())
return text, encoding


Expand Down

0 comments on commit 5edd15e

Please sign in to comment.