Skip to content

Commit c4c6a70

Browse files
author
Ángel González
committed
Store country names as unicode
On python2 we need to store the country names as unicode in order to avoid a mismatch on has_country() when the line has non-ascii characters (eg. aymorecfi.com.br)
1 parent 4d607ff commit c4c6a70

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pythonwhois/parse.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def read_dataset(filename, destination, abbrev_key, name_key, is_dict=False):
6060
# Because 'UK' is commonly used to refer to the United Kingdom, but formally not the ISO code...
6161
countries['UK'] = countries['GB']
6262

63-
country_names = set([name.lower() for name in countries.values()])
63+
if sys.version_info < (3, 0):
64+
country_names = set([name.decode('utf-8').lower() for name in countries.values()])
65+
else:
66+
country_names = set([name.lower() for name in countries.values()])
67+
6468

6569
def precompile_regexes(source, flags=0):
6670
return [re.compile(regex, flags) for regex in source]

0 commit comments

Comments
 (0)