This is a multi-part MIME message sent by reportbug.
Package: urwid
Version: 2.6.4-1
Severity: normal
Tags: patch
User:
ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch
Dear Maintainer,
With the version of urwid 2.6.4-1 currently in trixie, the following
code fails with an exception:
```python
from urwid import Pile
Pile([
("pack", Pile([])),
]).render((10,))
```
File "/usr/lib/python3/dist-packages/urwid/widget/widget.py", line 112, in cached_render
canv = fn(self, size, focus=focus)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urwid/widget/pile.py", line 822, in render
_widths, heights, size_args = self.get_rows_sizes(size, focus)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urwid/widget/pile.py", line 730, in get_rows_sizes
heights.append(w.pack(w_h_arg, item_focus)[1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urwid/widget/pile.py", line 744, in pack
return super().pack(size, focus)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urwid/widget/widget.py", line 401, in pack
raise WidgetError(f"Cannot pack (maxcol,) size, this is not a flow widget: {self!r}")
urwid.widget.widget.WidgetError: Cannot pack (maxcol,) size, this is not a flow widget: <Pile widget>
The same code used to work with urwid 2.1.2-4 in bookworm.
I applied a fix from upstream [1] that was included in urwid 2.6.5. I
think the proper way forward would be to take a more recent upstream
version of urwid. That said, we are in feature freeze downstream in
Ubuntu so I skipped the refactoring bits.
In Ubuntu, the attached patch was applied to achieve the following:
* Apply upstream patch to fix a crash when rendering an empty Pile or an
empty Columns as a flow widget. (LP: #2058388)
+ d/patches/fix-crash-empty-pile.patch
Thanks for considering the patch.
-- System Information:
Debian Release: trixie/sid
APT prefers noble
APT policy: (500, 'noble'), (100, 'noble-proposed')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.8.0-11-generic (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_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
[1]
https://github.com/urwid/urwid/commit/83c278b53de431a9b41d7ddadf5f318914246593
diff -Nru urwid-2.6.4/debian/patches/fix-crash-empty-pile.patch urwid-2.6.4/debian/patches/fix-crash-empty-pile.patch
--- urwid-2.6.4/debian/patches/fix-crash-empty-pile.patch 1970-01-01 01:00:00.000000000 +0100
+++ urwid-2.6.4/debian/patches/fix-crash-empty-pile.patch 2024-03-19 14:23:31.000000000 +0100
@@ -0,0 +1,158 @@
+Description: Fix crash when rendering empty Pile or Columns as a flow widget
+ Special case: in case of `Columns`/`Pile` empty - use fallback sizing (#843) + .
+ * Extend `repr` to provide brief info about contents
+ .
+Author: Aleksei Stepanov <
alekseis@nvidia.com>
+Origin: upstream,
https://github.com/urwid/urwid/commit/83c278b53de431a9b41d7ddadf5f318914246593
+Bug-Ubuntu:
https://launchpad.net/bugs/2058388
+Last-Update: 2024-03-19
+---
+This patch header follows DEP-3:
http://dep.debian.net/deps/dep3/
+diff --git a/urwid/widget/columns.py b/urwid/widget/columns.py
+index e3fa134..5a3421f 100644
+--- a/urwid/widget/columns.py
++++ b/urwid/widget/columns.py
+@@ -66,40 +66,47 @@ class Columns(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin):
+
+ # BOX-only widget