Skip to content

Commit

Permalink
allows windows to import file with non-ascii characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Apr 21, 2024
1 parent 54abc09 commit 2a8deea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python_hosts/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import sys
import codecs

try:
from urllib.request import urlopen
Expand Down Expand Up @@ -362,7 +363,7 @@ def import_file(self, import_file_path=None):
invalid_count = 0
if is_readable(import_file_path):
import_entries = []
with open(import_file_path, 'r', encoding='utf-8-sig') as infile:
with codecs.open(import_file_path, 'r', encoding='utf-8-sig') as infile:
for line in infile:
stripped_entry = line.strip()
if (not stripped_entry) or (stripped_entry.startswith('#')):
Expand Down

0 comments on commit 2a8deea

Please sign in to comment.