From abf2870b868f58548c48550cf495c3e440cc62c9 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@endlessm.com> Date: Thu, 5 Mar 2020 16:26:56 +0200 Subject: [PATCH] Decode responses. Responses from urlopen are bytes. Decode them using the default locale encoding. Supported since Python 2.3. --- update_repos | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_repos b/update_repos index ecc67b1..4749431 100755 --- a/update_repos +++ b/update_repos @@ -92,7 +92,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() + return urlopen(req).read().decode() def get_json(uri, config, obj_type=AttributeDict, page=1): return json.loads(read_api_uri(uri, config, page), object_hook=obj_type) @@ -283,7 +283,7 @@ class JsonRepo(object): print("Downloading %s" % target) data = read_api_uri(url, self.config) with open(target, 'wb') as dl_file: - dl_file.write(data) + dl_file.write(data.encode()) class IssuesRepo(JsonRepo): def __init__(self, gh_repo, config): -- GitLab