[3.8] bpo-33972: Fix EmailMessage.iter_attachments raising AttributeError (GH-14119) by maxking · Pull Request #14380 · python/cpython

@maxking

…rror. (pythonGH-14119)

* bpo-33972: Fix EmailMessage.iter_attachments raising AttributeError.

When certain malformed messages have content-type set to 'mulitpart/*' but
still have a single part body, iter_attachments can raise AttributeError. This
patch fixes it by returning a None value instead when the body is single part.
(cherry picked from commit 0225701)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>