Repository: urwid/urwid

Issue #496: Ellipsis wrap mode is supported only for UTF and limited list of other encodings
Created: 2022-01-30T06:46:05Z
In case of unsupported encoding, error will happen (text layout can not be correctly built).
Supported encodings:

big5
big5hkscs
cp874
cp932
cp949
cp950
cp1250
cp1251
cp1252
cp1253
cp1254
cp1255
cp1256
cp1257
cp1258
euc_jp
euc_jis_2004
euc_jisx0213
euc_kr
gb2312
gbk
gb18030
hz
iso2022_jp
iso2022_jp_1
iso2022_jp_2
iso2022_jp_2004
iso2022_jp_3
iso2022_jp_ext
iso2022_kr
johab
koi8_t
kz1048
mac_cyrillic
mac_greek
mac_iceland
mac_latin2
mac_roman
mac_turkish
ptcp154
shift_jis
shift_jis_2004
shift_jisx0213
utf_32
utf_32_be
utf_32_le
utf_16
utf_16_be
utf_16_le
utf_7
utf_8
utf_8_sig

Unsupported encodings:

ascii
cp037
cp273
cp424
cp437
cp500
cp720
cp737
cp775
cp850
cp852
cp855
cp856
cp857
cp858
cp860
cp861
cp862
cp863
cp864
cp865
cp866
cp869
cp875
cp1006
cp1026
cp1125
cp1140
latin_1
iso8859_2
iso8859_3
iso8859_4
iso8859_5
iso8859_6
iso8859_7
iso8859_8
iso8859_9
iso8859_10
iso8859_11
iso8859_13
iso8859_14
iso8859_15
iso8859_16
koi8_r
koi8_u

Duplicate issue #554: Error when using BigText: urwid.canvas.CanvasError: Attribute extends beyond text
Created: 2023-05-07T06:26:29Z
Description:
After upgrading from Python 3.10 to 3.11, I had to reinstall urwid, from 2.1.2 to 2.1.3.
Now using BigText, even from the example, gives the error below.
I tested other examples (graph, tour, fib) and they work.
I see now that the latest stable version is 2.1.2. Not sure why ArchLinux python-urwid package installed 2.1.3.
Installing 2.1.2 using pip solved the issue for me, even with Python 3.11.
$ python bigtext.py
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/urwid/font.py", line 243, in render
    canv = TextCanvas(byte_lines, None, character_set_lines, maxcol=width, check_width=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/canvas.py", line 402, in __init__
    raise CanvasError(f"Attribute extends beyond text \n{text[i]!r}\n{attr[i]!r}" )
urwid.canvas.CanvasError: Attribute extends beyond text 
b'      '
[(None, 16)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tmp/a/bigtext.py", line 163, in <module>
    main()
  File "/tmp/a/bigtext.py", line 160, in main
    BigTextDisplay().main()
  File "/tmp/a/bigtext.py", line 144, in main
    self.loop.run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 320, in run
    self._run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 423, in _run
    self.event_loop.run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/select_loop.py", line 148, in run
    self._loop()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/select_loop.py", line 185, in _loop
    alarm_callback()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 621, in entering_idle
    self.draw_screen()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 635, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/container.py", line 1567, in render
    body = self.body.render((maxcol, maxrow-ftrim-htrim),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/decoration.py", line 289, in render
    canv = self._original_widget.render(size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/listbox.py", line 518, in render
    focus_canvas = focus_widget.render((maxcol,), focus=focus)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/container.py", line 2147, in render
    canv = w.render((maxcol,), focus=focus and item_focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/decoration.py", line 518, in render
    canv = self._original_widget.render((maxcol, self.height), focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/decoration.py", line 1029, in render
    canv = self._original_widget.render((maxcol,), focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/decoration.py", line 289, in render
    canv = self._original_widget.render(size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/decoration.py", line 725, in render
    canv = self._original_widget.render((), focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/widget.py", line 149, in cached_render
    canv = fn(self, size, focus=focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/graphics.py", line 102, in render
    c = self.font.render(ch)
        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/font.py", line 245, in render
    raise CanvasError(
  File "/usr/lib/python3.11/site-packages/urwid/font.py", line 243, in render
    canv = TextCanvas(byte_lines, None, character_set_lines, maxcol=width, check_width=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urwid/canvas.py", line 402, in __init__
    raise CanvasError(f"Attribute extends beyond text \n{text[i]!r}\n{attr[i]!r}" )
urwid.canvas.CanvasError: Failed render of 'U' from line ['┬   ┬ ', '│   │ ', '│   │ ', '│   │ ', '└───┘ ', '      ']:
Thin6x6Font():
  6
  [   '\n'
    "000000111111222222333333444444555555666666777777888888999999''\n"
    '┌───┐   ┐   ┌───┐ ┌───┐    ┐  ┌───  ┌───  ┌───┐ ┌───┐ ┌───┐ │\n'
    '│   │   │       │     │ ┌  │  │     │         │ │   │ │   │\n'
    '│ / │   │   ┌───┘    ─┤ └──┼─ └───┐ ├───┐     ┼ ├───┤ └───┤\n'
    '│   │   │   │         │    │      │ │   │     │ │   │     │\n'
    '└───┘   ┴   └───  └───┘    ┴   ───┘ └───┘     ┴ └───┘  ───┘\n'
    '\n',
    '\n'
    '!!   """######$$$$$$%%%%%%&&&&&&((()))******++++++\n'
    '│    ││  ┌ ┌  ┌─┼─┐ ┌┐  /  ┌─┐   / \\\n'
    '│       ─┼─┼─ │ │   └┘ /   │ │  │   │  \\ /    │\n'
    '│        │ │  └─┼─┐   /   ┌─\\┘  │   │ ──X── ──┼──\n'
    '│       ─┼─┼─   │ │  / ┌┐ │  \\, │   │  / \\    │\n'
    '.        ┘ ┘  └─┼─┘ /  └┘ └───\\  \\ /\n'
    '\n',
    '\n'
    ',,-----..//////::;;<<<<=====>>>>??????@@@@@@\n'
    '             /                  ┌───┐ ┌───┐\n'
    '            /  . .   / ──── \\       │ │┌──┤\n'
    '  ────     /        /        \\    ┌─┘ ││  │\n'
    '          /    . ,  \\  ────  /    │   │└──┘\n'
    ',      . /           \\      /     .   └───┘\n'
    '\n',
    '\n'
    '[[\\\\\\\\\\\\]]^^^____``{{||}}~~~~~~\n'
    '┌ \\     ┐ /\\     \\ ┌ │ ┐\n'
    '│  \\    │          │ │ │ ┌─┐\n'
    '│   \\   │          ┤ │ ├   └─┘\n'
    '│    \\  │          │ │ │\n'
    '└     \\ ┘    ────  └ │ ┘\n'
    '\n',
    '\n'
    'AAAAAABBBBBBCCCCCCDDDDDDEEEEEEFFFFFFGGGGGGHHHHHHIIJJJJJJ\n'
    '┌───┐ ┬───┐ ┌───┐ ┬───┐ ┬───┐ ┬───┐ ┌───┐ ┬   ┬ ┬     ┬\n'
    '│   │ │   │ │     │   │ │     │     │     │   │ │     │\n'
    '├───┤ ├───┤ │     │   │ ├──   ├──   │ ──┬ ├───┤ │     │\n'
    '│   │ │   │ │     │   │ │     │     │   │ │   │ │ ┬   │\n'
    '┴   ┴ ┴───┘ └───┘ ┴───┘ ┴───┘ ┴     └───┘ ┴   ┴ ┴ └───┘\n'
    '\n',
    '\n'
    'KKKKKKLLLLLLMMMMMMNNNNNNOOOOOOPPPPPPQQQQQQRRRRRRSSSSSS\n'
    '┬   ┬ ┬     ┌─┬─┐ ┬─┐ ┬ ┌───┐ ┬───┐ ┌───┐ ┬───┐ ┌───┐\n'
    '│ ┌─┘ │     │ │ │ │ │ │ │   │ │   │ │   │ │   │ │\n'
    '├─┴┐  │     │ │ │ │ │ │ │   │ ├───┘ │   │ ├─┬─┘ └───┐\n'
    '│  └┐ │     │   │ │ │ │ │   │ │     │  ┐│ │ └─┐     │\n'
    '┴   ┴ ┴───┘ ┴   ┴ ┴ └─┴ └───┘ ┴     └──┼┘ ┴   ┴ └───┘\n'
    '                                       └\n',
    '\n'
    'TTTTTTUUUUUUVVVVVVWWWWWWXXXXXXYYYYYYZZZZZZ\n'
    '┌─┬─┐ ┬   ┬ ┬   ┬ ┬   ┬ ┬   ┬ ┬   ┬ ┌───┐\n'
    '  │   │   │ │   │ │   │ └┐ ┌┘ │   │   ┌─┘\n'
    '  │   │   │ │   │ │ │ │  ├─┤  └─┬─┘  ┌┘\n'
    '  │   │   │ └┐ ┌┘ │ │ │ ┌┘ └┐   │   ┌┘\n'
    '  ┴   └───┘  └─┘  └─┴─┘ ┴   ┴   ┴   └───┘\n'
    '\n',
    '\n'
    'aaaaaabbbbbbccccccddddddeeeeeefffgggggghhhhhhiijjj\n'
    '                              ┌─┐\n'
    '      │               │       │        │     .  .\n'
    '┌───┐ ├───┐ ┌───┐ ┌───┤ ┌───┐ ┼  ┌───┐ ├───┐ ┐  ┐\n'
    '┌───┤ │   │ │     │   │ ├───┘ │  │   │ │   │ │  │\n'
    '└───┴ └───┘ └───┘ └───┘ └───┘ ┴  └───┤ ┴   ┴ ┴  │\n'
    '                                 └───┘         ─┘\n',
    '\n'
    'kkkkkkllmmmmmmnnnnnnooooooppppppqqqqqqrrrrrssssss\n'
    '\n'
    '│     │\n'
    '│ ┌─  │ ┬─┬─┐ ┬───┐ ┌───┐ ┌───┐ ┌───┐ ┬──┐ ┌───┐\n'
    '├─┴┐  │ │ │ │ │   │ │   │ │   │ │   │ │    └───┐\n'
    '┴  └─ └ ┴   ┴ ┴   ┴ └───┘ ├───┘ └───┤ ┴    └───┘\n'
    '                          │         │\n',
    '\n'
    'ttttuuuuuuvvvvvvwwwwwwxxxxxxyyyyyyzzzzzz\n'
    '\n'
    ' │\n'
    '─┼─ ┬   ┬ ┬   ┬ ┬   ┬ ─┐ ┌─ ┬   ┬ ────┬\n'
    ' │  │   │ └┐ ┌┘ │ │ │  ├─┤  │   │ ┌───┘\n'
    ' └─ └───┴  └─┘  └─┴─┘ ─┘ └─ └───┤ ┴────\n'
    '                            └───┘\n']
:Attribute extends beyond text 
b'      '
[(None, 16)]

Affected versions (if applicable)

 master branch (specify commit)
 Latest stable version from pypi
 Other: 2.1.3

Steps to reproduce (if applicable)
Run bigtext.py.

Closing comment (2023-05-08T08:02:53Z): Related-to: #496