-
Notifications
You must be signed in to change notification settings - Fork 166
Closed
Description
Describe the bug
I received an e-mail without a body, just an attachment. Alot fails to open it.
Software Versions
- Python version: 3.8.2
- Notmuch version: 0.29.3
- Alot version: master
To Reproduce
Steps to reproduce the behaviour:
- try to open an e-mail without a body;
- Alot fails to open it.
Error Log
Traceback (most recent call last):
File "/home/martins/code/alot/alot/ui.py", line 195, in _apply_fire
await self.apply_commandline(cmdline)
File "/home/martins/code/alot/alot/ui.py", line 283, in apply_commandline
self._error_handler(e)
File "/home/martins/code/alot/alot/ui.py", line 160, in _error_handler
self.notify(msg, priority='error')
File "/home/martins/code/alot/alot/ui.py", line 624, in notify
self.update()
File "/home/martins/code/alot/alot/ui.py", line 660, in update
lines.append(self.build_statusbar())
File "/home/martins/code/alot/alot/ui.py", line 677, in build_statusbar
info = cb.get_info()
File "/home/martins/code/alot/alot/buffers/thread.py", line 60, in get_info
self.get_selected_message().get_mime_part().get_content_type())
AttributeError: 'str' object has no attribute 'get_content_type'
This is due to this function:
Lines 469 to 491 in 32b885d
| def get_body_part(mail, mimetype=None): | |
| """Returns an EmailMessage. | |
| This consults :ref:`prefer_plaintext <prefer-plaintext>` | |
| to determine if a "text/plain" alternative is preferred over a "text/html" | |
| part. | |
| :param mail: the mail to use | |
| :type mail: :class:`email.message.EmailMessage` | |
| :returns: The combined text of any parts to be used | |
| :rtype: str | |
| """ | |
| if not mimetype: | |
| mimetype = 'plain' if settings.get('prefer_plaintext') else 'html' | |
| preferencelist = { | |
| 'plain': ('plain', 'html'), 'html': ('html', 'plain')}[mimetype] | |
| body_part = mail.get_body(preferencelist) | |
| if body_part is None: # if no part matching preferredlist was found | |
| return "" | |
| return body_part |
Despite that :rtype: says str, it normally returns email.message.EmailMessage. And when there is no body it returns an empty string.
Which fails in
Lines 59 to 60 in 32b885d
| info['mimetype'] = ( | |
| self.get_selected_message().get_mime_part().get_content_type()) |
via
Lines 277 to 280 in 32b885d
| def get_mime_part(self): | |
| if not self._mime_part: | |
| self._mime_part = get_body_part(self.get_email()) | |
| return self._mime_part |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels