pimutils / khal

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

Ikhal crashes to create new events #1334

Closed d4rios closed 4 months ago

d4rios commented 5 months ago

Describe the bug

Hi, When I try to create new events in ikhal, it crashes miserably.

If applicable: Stack Trace: This is the output on my terminal

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 343, in run self._run() File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 445, 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 218, in _loop self._entering_idle() File "/usr/lib/python3.11/site-packages/urwid/event_loop/select_loop.py", line 171, in _entering_idle callback() File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 652, in entering_idle self.draw_screen() File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 669, in draw_screen canvas = self._topmost_widget.render(self.screen_size, focus=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/popup.py", line 118, in render self._update_overlay(size, focus) File "/usr/lib/python3.11/site-packages/urwid/widget/popup.py", line 91, in _update_overlay canv = self._original_widget.render(size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/frame.py", line 408, in render body = self.body.render((maxcol, maxrow - ftrim - htrim), focus and self.focus_part == "body") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/columns.py", line 938, in render w.render(w_size, focus=focus and self.focus_position == i), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/khal/ui/widgets.py", line 672, in render return super().render(size, focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 718, in render canv = get_delegate(self).render(size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/pile.py", line 817, in render canv = w.render(w_size, focus=focus and item_focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/columns.py", line 938, in render w.render(w_size, focus=focus and self.focus_position == i), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 718, in render canv = get_delegate(self).render(size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/listbox.py", line 640, in render canvas = widget.render((maxcol,)) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 718, in render canv = get_delegate(self).render(size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/pile.py", line 817, in render canv = w.render(w_size, focus=focus and item_focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/columns.py", line 938, in render w.render(w_size, focus=focus and self.focus_position == i), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 112, in cached_render canv = fn(self, size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 718, in render canv = get_delegate(self).render(size, focus=focus) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 113, in cached_render validate_size(self, size, canv) File "/usr/lib/python3.11/site-packages/urwid/widget/widget.py", line 92, in validate_size raise WidgetError( urwid.widget.widget.WidgetError: Widget <Padding selectable fixed/flow widget <CalendarPopUp selectable flow widget > right=1 width=11> rendered (11 x 1) canvas when passed size (10,)!

Expected behavior A clear and concise description of what you expected to happen. That new events in ikhal can be created.

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

The output of khal --version: 0.11.2: 
Installation method: pacman
python version: Python 3.11.6
OS: Archlinux 2024.02.01
Your khal config file:

[calendars]

[[Casa]] path = ~/.calendars/6C43D0F9-7DE6-4D08-BE77-5A8FC3C30429 type = discover color = light red

[[Personal]] path = ~/.calendars/D411412F-AA58-4602-8D3B-4C9AC6FBE4C5 type = discover color = light green

[[Trabajo]] path = ~/.calendars/154B5BEC-34AF-43A8-B23B-1D171FFE8A5F type = discover color = dark blue

[[Planning]] path = ~/.calendars/A462C994-F46D-4AF9-8EE0-120104BD5D67 type = discover color = light cyan

[locale] firstweekday = 0 timeformat = %H:%M dateformat = %d/%m/%Y longdateformat = %d/%m/%Y datetimeformat = %d/%m/%Y %H:%M longdatetimeformat = %d/%m/%Y %H:%M

[default] default_calendar = D411412F-AA58-4602-8D3B-4C9AC6FBE4C5 highlight_event_days = True

[highlight_days] color = light magenta method = fg

[view] dynamic_days = True frame = color

Thanks

d4rios commented 4 months ago

Sorry for that. Updating urwid to 2.4.1 versión my problem is gone. Ikhal is now working properly. Thank you in advance and I hope you will take this into account for future versions.

andrewferrier commented 4 months ago

I have the exact same issue (same error message), however for me using python-urwid 2.5.1 triggers the problem. If I downgrade to 2.4.1, then I can add events without the issue.

dvzrv commented 4 months ago

Hi! I have just opened a downstream issue about this, since with python-urwid 2.5.1-1 on Arch Linux khal is now broken: https://gitlab.archlinux.org/archlinux/packaging/packages/python-urwid/-/issues/1

dvzrv commented 4 months ago

Pinging @penguinolog for good measure (in case this has been triggered by a regression in urwid).

penguinolog commented 4 months ago

debugging, looks weird

WhyNotHugo commented 4 months ago

I'm pretty sure that this was fixed in master a few weeks ago.

penguinolog commented 4 months ago

I'm pretty sure that this was fixed in master a few weeks ago.

No, regression present and not covered by tests. Fix will be done ASAP (today) with extra tests for such scenario. Shrot details: Padding widget incorrectly calculate render size for Selectable Flow when no padding needed (input widget using full width).

UP: extra details: this happend, when Padding configured for bigger width, than in arguments for render: khal request Padding over widget with fixed width = 11 and then render with width = 10.

penguinolog commented 4 months ago

Technically urwid should not crash if behavior was supported before. Last refactoring exposed a lot of incorrect usage cases, which worked due to skipped validation (even if correct usage was explained many years ago). I see #1328 fix in khal, but other packages with the same issues may be available.

dvzrv commented 4 months ago

I'm pretty sure that this was fixed in master a few weeks ago.

It would be great to see a release for this fix! In the meantime this has been patched on the downstream khal package: https://gitlab.archlinux.org/archlinux/packaging/packages/khal/-/commit/8b110226353dbb8caec2c06184df541da01386da

@penguinolog Thanks for the investigation and background info!

penguinolog commented 4 months ago

Urwid 2.5.3 was released specially for this case. (BTW, new khal release with #1328 will be great)

geier commented 4 months ago

Should be fixed with https://github.com/pimutils/khal/releases/tag/v0.11.3

geier commented 4 months ago

@penguinolog thanks for taking care of this in urwid!