Package: reportbug Version: 12.0.0 Severity: normal X-Debbugs-Cc: none, Asher Gordon <AsDaGo@posteo.net> Dear Maintainer, -- Package-specific info:
** Environment settings: EDITOR="/home/asher/.config/fish/scripts/emacsclient.fish"
When passing multiple bug numbers on the command line, the querybts script crashes. Example: $ querybts 1000000 1000001 Querying Debian BTS for reports on 1000000 1000001... 2 bug reports found: Traceback (most recent call last): File "/usr/bin/querybts", line 241, in <module> main() File "/usr/bin/querybts", line 217, in main ui.handle_bts_query(package, options.system, options.timeout, options.mirrors, options.http_proxy, File "/usr/lib/python3/dist-packages/reportbug/ui/text_ui.py", line 603, in handle_bts_query package = [p[4:] for p in package if p.startswith("src:")][0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/reportbug/ui/text_ui.py", line 603, in <listcomp> package = [p[4:] for p in package if p.startswith("src:")][0] ^^^^^^^^^^^^ AttributeError: 'int' object has no attribute 'startswith' This is because of a chunk of code introduced in 9855d71: # only pass a single package name to browse_bugs if isinstance(package, list): package = [p[4:] for p in package if p.startswith("src:")][0] source = True This code is problematic for several reasons. 1. The elements of 'package' are integers, not strings (I am not sure under what circumstances they would be strings). This is what causes the crash. 2. Even if we fix problem 1 (e.g. s/if p/if str(p)/), this code still fails if none of the packages begin with the string 'src:', because the list comprehension will result in an empty list, for which 0 is an invalid index. 3. There is no need for a list comprehension at all (or even a loop), since we only take the 0th element. 4. Even if this code did what I believe it intended to do (more or less 'package = package[0]'), this does not align with expected behavior. The help text for the 'b' command says 'Open the complete bugs list in a web browser.' Note that it does not say 'Open the first bug in a web browser.' I believe all of these problems can be fixed by a) Reverting 9855d71. b) Changing browse_bugs() and search_bugs() to call launch_browser() multiple times (once for each package). c) Changing launch_browser() to run xdg-open in the background so that all the bugs are opened in separate tabs, and you don't have to close the browser to see the next bug. webbrowser().open() automatically runs the browser in the background as far as I can tell, so we don't have to worry about that part. I have done all of these things in the patch below:
From 2037bac77dae3e49162780277ff0501726bc6bf0 Mon Sep 17 00:00:00 2001 From: Asher Gordon <AsDaGo@posteo.net> Date: Tue, 3 Oct 2023 00:51:18 -0400 Subject: [PATCH] Fix browsing multiple bugs from the command line. --- reportbug/ui/text_ui.py | 15 +++++---------- reportbug/urlutils.py | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py index bd8bd83..af316fb 100644 --- a/reportbug/ui/text_ui.py +++ b/reportbug/ui/text_ui.py @@ -598,11 +598,6 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="", else: ewrite('%d bug reports found:\n\n', count) - # only pass a single package name to browse_bugs - if isinstance(package, list): - package = [p[4:] for p in package if p.startswith("src:")][0] - source = True - return browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors, http_proxy, timeout, screen, title, package, source, mbox_reader_cmd) @@ -690,10 +685,9 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors, lastpage = [] break elif x == 'b': - if source: - launch_browser('https://bugs.debian.org/src:%s' % package) - else: - launch_browser('https://bugs.debian.org/%s' % package) + for p in package: + launch_browser('https://bugs.debian.org/%s%s' % + (('src:' if source else ''), p)) continue elif x == 'r': continue @@ -910,7 +904,8 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors, lastpage = [] break elif x == 'b': - launch_browser('https://bugs.debian.org/%s' % package) + for p in package: + launch_browser('https://bugs.debian.org/%s' % p) elif x == 'r': continue elif x == 'q': diff --git a/reportbug/urlutils.py b/reportbug/urlutils.py index efc4062..2728262 100644 --- a/reportbug/urlutils.py +++ b/reportbug/urlutils.py @@ -139,7 +139,7 @@ def launch_browser(url): None """ if not os.system('command -v xdg-open >/dev/null 2>&1'): - cmd = 'xdg-open ' + shlex.quote(url) + cmd = 'xdg-open ' + shlex.quote(url) + ' &' os.system(cmd) return -- 2.40.1
Thanks, Asher -- System Information: Debian Release: trixie/sid APT prefers testing-debug APT policy: (500, 'testing-debug'), (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 6.5.0-1-amd64 (SMP w/12 CPU threads; PREEMPT) Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages reportbug depends on: ii apt 2.7.6 ii python3 3.11.4-5+b1 ii python3-reportbug 12.0.0 ii sensible-utils 0.0.20 reportbug recommends no packages. Versions of packages reportbug suggests: pn claws-mail <none> ii debconf 1.5.82 pn debsums <none> pn dlocate <none> ii emacs-bin-common 1:29.1+1-5 ii exim4-daemon-light [mail-transport-agent] 4.97~RC0-3 ii file 1:5.45-2 ii gnupg 2.2.40-1.1 pn python3-urwid <none> pn reportbug-gtk <none> ii xdg-utils 1.1.3-4.1 Versions of packages python3-reportbug depends on: ii apt 2.7.6 ii file 1:5.45-2 ii python3 3.11.4-5+b1 ii python3-apt 2.6.0 ii python3-debian 0.1.49 ii python3-debianbts 4.0.1 ii python3-requests 2.31.0+dfsg-1 ii sensible-utils 0.0.20 python3-reportbug suggests no packages. -- no debconf information -- The difference between the right word and the almost right word is the difference between lightning and the lightning bug. -- Mark Twain -------- I prefer to send and receive mail encrypted. Please send me your public key, and if you do not have my public key, please let me know. Thanks. GPG fingerprint: 38F3 975C D173 4037 B397 8095 D4C9 C4FC 5460 8E68
Attachment:
signature.asc
Description: PGP signature