This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new f0dce33  fix some more warnings from mypy
f0dce33 is described below

commit f0dce3379b62b63235fc4be4c3e5a2d4a80c2941
Author: Daniel Gruno <[email protected]>
AuthorDate: Tue Aug 18 01:57:31 2020 +0200

    fix some more warnings from mypy
    
    Also fix edge case where body can be None (if no body could be found in
    an email at all)
---
 tools/archiver.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index c1dbf6e..755dfeb 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -175,7 +175,7 @@ class Body:
                 if cs:
                     try:
                         self.string = contents.decode(cs)
-                        self.character_set = cs
+                        self.character_set = str(cs)
                     except UnicodeDecodeError:
                         pass
             if not self.string:
@@ -248,7 +248,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
 
     def message_body(
         self, msg: email.message.Message, verbose=False, ignore_body=None
-    ) -> Body:
+    ) -> typing.Optional[Body]:
         """
             Fetches the proper text body from an email as an archiver.Body 
object
         :param msg: The email or part of it to examine for proper body
@@ -267,7 +267,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
                 Note: cannot use break here because firstHTML is needed if 
len(body) <= 1
             """
             try:
-                if not body and part.get_content_type() in [
+                if body is None and part.get_content_type() in [
                     "text/plain",
                     "text/enriched",
                 ]:
@@ -424,7 +424,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
                 "private": private,
                 "references": msg_metadata["references"],
                 "in-reply-to": irt,
-                "body": body.unflow(),
+                "body": body.unflow() if body else '',
                 "attachments": attachments,
             }
 

Reply via email to