control: tags 859274 patch Thanks for reporting this. Here's a patch.
>From cbe84151785b180188d5df9c26f42714e82e9451 Mon Sep 17 00:00:00 2001 From: Nis Martensen <nis.marten...@web.de> Date: Sat, 22 Apr 2017 11:27:37 +0200 Subject: [PATCH 1/2] Finish open_url return type conversion
The return type of reportbug/urlutils/open_url() was changed in commit 5cf006943001a94bfafe0a40adbb1241950853de from http.client.HTTPResponse to string. A few remaining open_url() callers have not yet been updated, leading to breakage such as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859274 This commit updates the remaining callers to deal with strings, and updates a few places to iterate over lines rather than characters. --- bin/querybts | 4 ++-- reportbug/debbugs.py | 23 +++-------------------- reportbug/utils.py | 2 +- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/bin/querybts b/bin/querybts index 229dde9..ee79949 100755 --- a/bin/querybts +++ b/bin/querybts @@ -168,7 +168,7 @@ def main(): url = debbugs.get_report_url(options.system, num, options.archived, mbox=True) try: report = urlutils.open_url(url, timeout=options.timeout) - sys.stdout.write(report.read()) + sys.stdout.write(report) except urlutils.urllib2.URLError as ex: print("Error while accessing mbox report (%s)." % ex, file=sys.stderr) else: @@ -176,7 +176,7 @@ def main(): url = debbugs.get_report_url(options.system, num, options.archived, mbox=True) try: report = urlutils.open_url(url, timeout=options.timeout) - sys.stdout.write(report.read()) + sys.stdout.write(report) except urlutils.urllib2.URLError as ex: print("Error while accessing mbox report (%s)." % ex, file=sys.stderr) sys.exit(1) diff --git a/reportbug/debbugs.py b/reportbug/debbugs.py index 19ee02e..d71b303 100644 --- a/reportbug/debbugs.py +++ b/reportbug/debbugs.py @@ -967,16 +967,10 @@ def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=Tru return None parser = BTSParser(cgi=cgi, followups=followups) - for line in page: + for line in page.splitlines(): parser.feed(line) parser.close() - try: - page.fp._sock.recv = None - except: - pass - page.close() - items = parser.preblock title = "#%d: %s" % (number, parser.title) @@ -1011,13 +1005,7 @@ def parse_mbox_report(number, url, http_proxy, timeout, followups=False): return None # Make this seekable - wholefile = io.StringIO(page.read()) - - try: - page.fp._sock.recv = None - except: - pass - page.close() + wholefile = io.StringIO(page) mbox = mailbox.UnixMailbox(wholefile, msgfactory) title = '' @@ -1131,14 +1119,9 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None, # return (0, None, None) parser = BTSParser() - for line in page: + for line in page.splitlines(): parser.feed(line) parser.close() - try: - page.fp._sock.recv = None - except: - pass - page.close() return parser.bugcount, parser.title, parser.hierarchy diff --git a/reportbug/utils.py b/reportbug/utils.py index e134bcd..2a5bea1 100644 --- a/reportbug/utils.py +++ b/reportbug/utils.py @@ -1196,7 +1196,7 @@ def launch_mbox_reader(cmd, url, http_proxy, timeout): return (fd, fname) = TempFile() try: - for line in mbox: + for line in mbox.splitlines(): fd.write(line) fd.close() if cmd is not None: -- 2.1.4