bpo-42892: fix email multipart attribute error (GH-26903) (GH-27492)
(cherry picked from commit e3f877c32d7cccb734f45310f26beeec793364ce)
Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
diff --git a/Lib/email/message.py b/Lib/email/message.py
index db30d9a..6752ce0 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -982,7 +982,7 @@ def _find_body(self, part, preferencelist):
if subtype in preferencelist:
yield (preferencelist.index(subtype), part)
return
- if maintype != 'multipart':
+ if maintype != 'multipart' or not self.is_multipart():
return
if subtype != 'related':
for subpart in part.iter_parts():
@@ -1087,7 +1087,7 @@ def iter_parts(self):
Return an empty iterator for a non-multipart.
"""
- if self.get_content_maintype() == 'multipart':
+ if self.is_multipart():
yield from self.get_payload()
def get_content(self, *args, content_manager=None, **kw):