email.message_from_bytes() using modern email.policy.default. Returns a modern email.message.EmailMessage.
(s)
| 108 | |
| 109 | |
| 110 | def message_from_bytes(s): |
| 111 | """ |
| 112 | email.message_from_bytes() using modern email.policy.default. |
| 113 | Returns a modern email.message.EmailMessage. |
| 114 | """ |
| 115 | # The modern email parser has a bug with adjacent rfc2047 encoded-words. |
| 116 | # This doesn't affect django.core.mail (which doesn't parse messages), |
| 117 | # but it can confuse our tests that try to verify sent content by reparsing |
| 118 | # the generated message. Apply a workaround if needed. |
| 119 | message = _message_from_bytes(s, policy=policy.default) |
| 120 | if NEEDS_CPYTHON_128110_WORKAROUND and RFC2047_PREFIX.encode() in s: |
| 121 | _apply_cpython_128110_workaround(message, s) |
| 122 | return message |
| 123 | |
| 124 | |
| 125 | class MailTestsMixin: |
no test coverage detected