From 28dbfc3265c92065db6f793b05c6f6d22b3f9715 Mon Sep 17 00:00:00 2001 From: "Tobias Wellnitz, DH1TW" Date: Sun, 28 Jan 2018 00:28:49 +0100 Subject: [PATCH] explicit encoding to UTF-8 on json.loads() --- pyhamtools/lookuplib.py | 8 ++++---- pyhamtools/qsl.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyhamtools/lookuplib.py b/pyhamtools/lookuplib.py index 68aa674..881b10a 100644 --- a/pyhamtools/lookuplib.py +++ b/pyhamtools/lookuplib.py @@ -695,7 +695,7 @@ class LookupLib(object): if not self._check_html_response(response): raise LookupError - jsonLookup = json.loads(response.text) + jsonLookup = json.loads(response.text, encoding='UTF-8') lookup = {} for item in jsonLookup: @@ -989,7 +989,7 @@ class LookupLib(object): return True def _load_countryfile(self, - url="http://www.country-files.com/cty/cty.plist", + url="https://www.country-files.com/cty/cty.plist", country_mapping_filename="countryfilemapping.json", cty_file=None): """ Load and process the ClublogXML file either as a download or from file @@ -1385,7 +1385,7 @@ class LookupLib(object): mapping = None with open(country_mapping_filename, "r") as f: - mapping = json.loads(f.read()) + mapping = json.loads(f.read(), encoding='UTF-8') cty_list = plistlib.readPlist(cty_file) @@ -1473,7 +1473,7 @@ class LookupLib(object): Deserialize a JSON into a dictionary """ - my_dict = json.loads(json_data) + my_dict = json.loads(json_data, encoding='UTF-8') for item in my_dict: if item == const.ADIF: diff --git a/pyhamtools/qsl.py b/pyhamtools/qsl.py index d699a01..99f6efe 100644 --- a/pyhamtools/qsl.py +++ b/pyhamtools/qsl.py @@ -121,7 +121,7 @@ def get_clublog_users(**kwargs): files = zip_file.namelist() cl_json_unzipped = zip_file.read(files[0]) - cl_data = json.loads(cl_json_unzipped) + cl_data = json.loads(cl_json_unzipped, encoding='UTF-8') error_count = 0