From 94e1d62ad5464463a2ae8c5abbd110af51f76bbc Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sun, 11 Sep 2016 01:14:31 -0700 Subject: [PATCH] Fix byte/string conversion for python 3 --- bin/github-backup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/github-backup b/bin/github-backup index 186e2a0..ec3f738 100755 --- a/bin/github-backup +++ b/bin/github-backup @@ -271,7 +271,7 @@ def get_auth(args, encode=True): if encode == False: return auth - return base64.b64encode(auth) + return base64.b64encode(auth.encode('ascii')) def get_github_api_host(args): @@ -326,7 +326,7 @@ def retrieve_data(args, template, query_args=None, single_request=False): errors.append(template.format(status_code, r.reason)) log_error(errors) - response = json.loads(r.read()) + response = json.loads(r.read().decode('utf-8')) if len(errors) == 0: if type(response) == list: data.extend(response) @@ -382,7 +382,7 @@ def _construct_request(per_page, page, query_args, template, auth): request = Request(template + '?' + querystring) if auth is not None: - request.add_header('Authorization', 'Basic ' + auth) + request.add_header('Authorization', 'Basic '.encode('ascii') + auth) return request