pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.54k stars 197 forks source link

khal 0.11.3 with urwid 2.6.1 crashes on editing event #1340

Closed dvzrv closed 4 months ago

dvzrv commented 4 months ago

Describe the bug When pressing 'e' on an existing event in ikhal, the application crashes.

If applicable: Stack Trace

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/khal/ui/__init__.py", line 1363, in start_pane
    loop.run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 342, in run
    self._run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 444, in _run
    self.event_loop.run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/select_loop.py", line 182, in run
    self._loop()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/select_loop.py", line 229, in _loop
    record.data()
  File "/usr/lib/python3.11/site-packages/urwid/display/_posix_raw_display.py", line 274, in wrapper
    return self.parse_input(event_loop, callback, self.get_available_raw_input())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/display/_raw_display_base.py", line 489, in parse_input
    callback(decoded_codes, raw_codes)
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 471, in _update
    self.process_input(keys)
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 571, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)  # noqa: PLW2901
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/popup.py", line 140, in keypress
    return self._current_widget.keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/frame.py", line 451, in keypress
    return self.body.keypress((maxcol, remaining), key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/khal/ui/__init__.py", line 1123, in keypress
    return super().keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/khal/ui/base.py", line 114, in keypress
    return super().keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 736, in keypress
    return get_delegate(self).keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/khal/ui/widgets.py", line 313, in keypress
    key = super().keypress(size, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/columns.py", line 1129, in keypress
    key = w.keypress(size_args[i], key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 736, in keypress
    return get_delegate(self).keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/khal/ui/__init__.py", line 917, in keypress
    self.export_event()
  File "/usr/lib/python3.11/site-packages/khal/ui/__init__.py", line 787, in export_event
    overlay = urwid.Overlay(
              ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget/overlay.py", line 166, in __init__
    self.set_overlay_parameters(align, width, valign, height, min_width, min_height, left, right, top, bottom)
  File "/usr/lib/python3.11/site-packages/urwid/widget/overlay.py", line 459, in set_overlay_parameters
    self.options(
  File "/usr/lib/python3.11/site-packages/urwid/widget/overlay.py", line 362, in options
    VAlign(valign_type),
    ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: <WHSettings.RELATIVE: 'relative'> is not a valid VAlign

To Reproduce Open ikhal, press 'e' on existing event.

Expected behavior Khal does not crash.

Screenshots n/a

OS, version, khal version and how you installed it:

Additional context Add any other context about the problem here. Especially, if the issue came up when reading an .ics file, please provide the content of that file (anonymize if needed).

dvzrv commented 4 months ago

@geier any ideas? khal is currently broken on Arch Linux due to this issue :sweat_smile:

geier commented 4 months ago

I can confirm this bug, but I'm not sure yet if this is an issue with khal or urwid. Still happens with urwid 2.6.7

geier commented 4 months ago

This commit fixes the issue, but moves the export dialog to the top.

But according to urwid's documentation, a value of ('relative', 50) should be fine for valign.

geier commented 4 months ago

I have submitted an issue at https://github.com/urwid/urwid/issues/851

geier commented 4 months ago

The issue is fixed with urwid 2.6.8. I might implement a workaround for urwid version 2.4.3-2.6.7, but no guarantees.

dvzrv commented 4 months ago

@geier thanks for looking into this! I'll bump the urwid package on Arch Linux (in the hopes that it won't introduce regressions for other consumers :smiling_face_with_tear: )

geier commented 4 months ago

If upgrading urwid breaks something else, please ping me again.

dvzrv commented 4 months ago

in the hopes that it won't introduce regressions for other consumers

This was mostly meant "in regards to other packages using urwid". So far there have been no other complaints though, so I guess it's safe to say that this is fixed with 2.6.8! :tada: