Skip to content

Commit

Permalink
read file with encoding UTF-8 when detecting file encoding
Browse files Browse the repository at this point in the history
When reading a file with default encoding there can be errors
if the file encoding is incompatible to the default encoding.

Read the file with UTF-8 to catch many, if not all, of those cases.
  • Loading branch information
ralfth committed Dec 2, 2021
1 parent 6346d4d commit ae699ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mergepom.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_project_version(f):
and current_branch_version != other_branch_version
and other_branch_version != ancestor_version
):
with open(sys.argv[2], 'r') as f:
with open(sys.argv[2], mode='r', encoding='utf-8') as f:
enc = get_enc(f.readline(), 'utf-8')
with codecs.open(sys.argv[2], 'r', enc) as f:
other = f.read()
Expand Down

0 comments on commit ae699ae

Please sign in to comment.