Skip to content

Commit

Permalink
Close file when reading encoding
Browse files Browse the repository at this point in the history
Fix #66.
  • Loading branch information
liZe committed Jul 29, 2024
1 parent 099eeb7 commit 6f3f769
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyphen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def __init__(self, path):
self.patterns = {}

# see "man 4 hunspell", iscii-devanagari is not supported by python
encoding = path.open('rb').readline().decode()
with path.open('rb') as fd:
encoding = fd.readline().decode()
if encoding.lower() == 'microsoft-cp1251':
encoding = 'cp1251'

Expand Down

0 comments on commit 6f3f769

Please sign in to comment.