urlscan: start(): __init__.py:338:__getattr__:AttributeError: decoration not found in urwid
Closed this issue · 2 comments
Downstream bug:
https://bugzilla.redhat.com/show_bug.cgi?id=2277705
On my Fedora 40 system, I just tried to use urlscan
with my neomutt (as I always do). Searching using /
causes urlscan to crash:
Description of problem:
- start neomutt
- hit
ctrl v
to call up urlscan (.neomuttrc
has:macro index,pager \cv "<enter-command> unset pipe_decode<enter><pipe-message>urlscan -d --headers<enter>" "get URLs"
) - in the urlscan view, use the search function (
/
) - watch it crash
This was inside tmux (byobu), but I tried it out just in a gnome-terminal window and still saw it crash. A simpler reproducer is:
- in a directory with text files that contain urls, run:
- rg http | urlscan
- in urlscan view, try searching using
/
- watch it crash
Version-Release number of selected component:
urlscan-1.0.1-2.fc40
Additional info:
reporter: libreport-2.17.15
crash_function: start
kernel: 6.8.8-300.fc40.x86_64
cmdline: /usr/bin/python3 -sP /usr/bin/urlscan -d --headers
cgroup: 0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/tmux-spawn-a2956d99-6a05-4d5c-9640-9191232a6d56.scope
interpreter: python3-3.12.3-2.fc40.x86_64
uid: 1000
reason: init.py:338:getattr:AttributeError: decoration not found in urwid
package: urlscan-1.0.1-2.fc40
comment: Use the search function (/
)
exception_type: urwid.event_loop.main_loop.CantUseExternalLoop
executable: /usr/bin/urlscan
type: Python3
runlevel: N 5
Truncated backtrace:
__init__.py:338:__getattr__:AttributeError: decoration not found in urwid
Traceback (most recent call last):
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 436, in _run
self.start()
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 401, in start
raise CantUseExternalLoop(f"Screen {self.screen!r} doesn't support external event loops")
urwid.event_loop.main_loop.CantUseExternalLoop: Screen <urwid.display.curses.Screen object at 0x7fba4e551370> doesn't support external event loops
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/urlscan", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/lib/python3.12/site-packages/urlscan/__main__.py", line 191, in main
tui.main()
File "/usr/lib/python3.12/site-packages/urlscan/urlchoose.py", line 263, in main
self.loop.run()
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 343, in run
self._run()
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 439, in _run
self._run_screen_event_loop()
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 510, in _run_screen_event_loop
self.process_input(keys)
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 595, in process_input
something_handled |= bool(self.unhandled_input(k))
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/urwid/event_loop/main_loop.py", line 641, in unhandled_input
return self._unhandled_input(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/urlscan/urlchoose.py", line 339, in unhandled
self.keys[key]()
File "/usr/lib/python3.12/site-packages/urlscan/urlchoose.py", line 479, in _search_key
self._search()
File "/usr/lib/python3.12/site-packages/urlscan/urlchoose.py", line 702, in _search
if isinstance(col[0], urwid.decoration.AttrMap):
^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/urwid/__init__.py", line 338, in __getattr__
raise AttributeError(f"{name} not found in {__package__}")
AttributeError: decoration not found in urwid
Local variables in innermost frame:
name: 'decoration'
The only change i can see is the version on urlwid:
python3-urwid-2.5.3-2.fc40.x86_64
On F39, we were still at python3-urwid-2.1.2-10.fc39, and I hadn't noticed the issue there at all.
Seems something changed in urwid:
python
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
(ins)>>> import urwid
(ins)>>> urwid.decoration.AttrMap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.12/site-packages/urwid/__init__.py", line 338, in __getattr__
raise AttributeError(f"{name} not found in {__package__}")
AttributeError: decoration not found in urwid
but this works:
(ins)>>> import urwid.decoration
(ins)>>> urwid.decoration.AttrMap
<class 'urwid.widget.attr_map.AttrMap'>
so, perhaps we just need to add the import.decoration
line in there. I'll try this out and submit a PR.