Skip to content

Commit

Permalink
Fix bug with encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
Galactic647 committed Apr 15, 2023
1 parent 6efb899 commit 0616945
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Hash Fixer/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def remove_option(self, section: str, option: str) -> None:
del self[section][option]

def read(self, filename: str) -> None:
with open(filename, 'r') as file:
with open(filename, 'r', encoding='utf-8') as file:
self.read_file(file)
file.close()

Expand Down
8 changes: 4 additions & 4 deletions Hash Fixer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def load_hash() -> set:
open('common_hash.txt', 'w').close()
return set()

with open('common_hash.txt', 'r') as file:
with open('common_hash.txt', 'r', encoding='utf-8') as file:
common_hash = set(line.strip() for line in file.readlines())
file.close()
return common_hash
Expand All @@ -94,7 +94,7 @@ def create_config(self) -> None:
self.config.add_comment('However this is only will skip the related config instead of parsing it', 'Settings')
self.config.set('Settings', 'suppress_no_header_error', json.dumps(self.suppress_no_header_err))

with open('config.ini', 'w') as file:
with open('config.ini', 'w', encoding='utf-8') as file:
self.config.write(file)
file.close()
if self.mod_folder is not None:
Expand Down Expand Up @@ -159,7 +159,7 @@ def collect_hash(self) -> list:
hashes = set(hash_ for hash_ in hashes if hashes.count(hash_) > 1)
old_hashes.update(hashes.difference(old_hashes))

with open('common_hash.txt', 'w') as file:
with open('common_hash.txt', 'w', encoding='utf-8') as file:
file.write('\n'.join(old_hashes))
file.close()
return old_hashes
Expand Down Expand Up @@ -209,7 +209,7 @@ def process(self, ini: str) -> None:
self.mod_config.remove_option(section, 'match_priority')
logger.info(f"Config {ini_name}: deleting 'match_priority' from section -> {section}")

with open(ini, 'w') as file:
with open(ini, 'w', encoding='utf-8') as file:
self.mod_config.write(file)
file.close()

Expand Down

0 comments on commit 0616945

Please sign in to comment.