From bc24ef23de14f42a655cc33401044ad1fca136ac Mon Sep 17 00:00:00 2001 From: Logan Rosen Date: Mon, 22 Feb 2021 22:24:52 -0500 Subject: [PATCH] sponsor-patch: fix bugs from py3 migration --- ubuntutools/question.py | 2 +- ubuntutools/sponsor_patch/bugtask.py | 2 +- ubuntutools/sponsor_patch/patch.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ubuntutools/question.py b/ubuntutools/question.py index 32e3dee..d76cbdd 100644 --- a/ubuntutools/question.py +++ b/ubuntutools/question.py @@ -82,7 +82,7 @@ def input_number(question, min_number, max_number, default=None): else: question += "? " selected = None - while selected < min_number or selected > max_number: + while not selected or selected < min_number or selected > max_number: try: selected = input(question).strip() except (EOFError, KeyboardInterrupt): diff --git a/ubuntutools/sponsor_patch/bugtask.py b/ubuntutools/sponsor_patch/bugtask.py index d7b12ed..7c75037 100644 --- a/ubuntutools/sponsor_patch/bugtask.py +++ b/ubuntutools/sponsor_patch/bugtask.py @@ -74,7 +74,7 @@ class BugTask(object): if url.endswith(".dsc"): response, data = httplib2.Http().request(url) assert response.status == 200 - with open(filename, 'w') as f: + with open(filename, 'wb') as f: f.write(data) dsc_file = os.path.join(os.getcwd(), filename) diff --git a/ubuntutools/sponsor_patch/patch.py b/ubuntutools/sponsor_patch/patch.py index 1fbda60..7e12242 100644 --- a/ubuntutools/sponsor_patch/patch.py +++ b/ubuntutools/sponsor_patch/patch.py @@ -68,7 +68,7 @@ class Patch(object): def download(self): """Downloads the patch from Launchpad.""" Logger.debug("Downloading %s." % (self._patch_file)) - patch_f = open(self._patch_file, "w") + patch_f = open(self._patch_file, "wb") patch_f.write(self._patch.data.open().read()) patch_f.close()