From 952c4c560e5b1c4462f3deb481bbaea9b93f1460 Mon Sep 17 00:00:00 2001 From: Srdjan Grubor <sgnn7@sgnn7.org> Date: Fri, 13 Mar 2020 09:41:39 -0500 Subject: [PATCH] Make sure to decode web responses with UTF-8 Without this, running this code on python2 fails with the following: `UnicodeDecodeError: 'ascii' codec can't decode byte ... in position ...: ordinal not in range(128)` Python3 is fine since it uses utf8 by default. --- update_repos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_repos b/update_repos index 0874818..60e2a6c 100755 --- a/update_repos +++ b/update_repos @@ -97,7 +97,7 @@ def read_api_uri(uri, config, page=1): print("Trying URI {} with headers {}".format(uri, headers)) req = Request(uri, headers=headers) - return urlopen(req).read().decode() + return urlopen(req).read().decode('utf-8') def get_json(uri, config, obj_type=AttributeDict, page=1): return json.loads(read_api_uri(uri, config, page), object_hook=obj_type) -- GitLab