pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
700 stars 163 forks source link

togglemimepart applied on messages with empty body breaks the UI #1515

Open pazz opened 4 years ago

pazz commented 4 years ago

I have an email with an attachment that contains no body (just and empty string). Selecting this mail in thread mode and triggering togglemimepart yields the following.

Traceback (most recent call last):
  File "/home/pazz/.local/bin/alot", line 11, in <module>
    load_entry_point('alot', 'console_scripts', 'alot')()
  File "/home/pazz/projects/alot/alot/__main__.py", line 137, in main
    UI(dbman, cmdstring)
  File "/home/pazz/projects/alot/alot/ui.py", line 146, in __init__
    self.mainloop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 1340, in run
    reraise(*exc_info)
  File "/usr/lib/python3/dist-packages/urwid/compat.py", line 58, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 1354, in wrapper
    rval = f(*args,**kargs)
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 1313, in _twisted_idle_callback
    callback()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 572, in entering_idle
    self.draw_screen()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 586, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/decoration.py", line 226, in render
    canv = self._original_widget.render(size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 1085, in render
    body = self.body.render((maxcol, maxrow-ftrim-htrim),
  File "/home/pazz/projects/alot/alot/buffers/thread.py", line 138, in render
    return self.body.render(size, focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 1765, in render
    canv = get_delegate(self).render(size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 470, in render
    middle, top, bottom = self.calculate_visible(
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 353, in calculate_visible
    self._set_focus_complete( (maxcol, maxrow), focus )
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 734, in _set_focus_complete
    middle,top,bottom=self.calculate_visible((maxcol,maxrow),focus)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 356, in calculate_visible
    focus_widget, focus_pos = self._body.get_focus()
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/widgets.py", line 75, in get_focus
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/widgets.py", line 68, in _get
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/widgets.py", line 54, in __getitem__
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/nested.py", line 88, in get_decorated
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/nested.py", line 84, in _get_decorated_entry
  File "/home/pazz/.local/lib/python3.8/site-packages/urwidtrees-1.0.3.dev0-py3.8.egg/urwidtrees/decoration.py", line 472, in decorate
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 1768, in _