You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
email: set_content() raises AttributeError for memoryview with 7bit, 8bit or binary CTE #159858
email.contentmanager.raw_data_manager explicitly registers memoryview with the same handler as bytes and bytearray, but EmailMessage.set_content() raises AttributeError for a memoryview payload when the content transfer encoding is 7bit, 8bit, or binary.
The same calls succeed with bytes or bytearray payloads. Expected: support the registered memoryview input just as for those other bytes-like inputs, preserving the payload. For 7bit, non-ASCII input should still raise UnicodeDecodeError, as it does with bytes.
The failure comes from calling data.decode() in set_bytes_content(). The existing base64 memoryview path is already covered by test_set_image_jpg in test_email.test_contentmanager.
This reproduces on CPython main at ddc647a, Python 3.16.0a1+dev, on macOS arm64.
Rechecked on October 20: the content manager from current main (4c73f50) still raises AttributeError in all three cases. The affected implementation and test files are unchanged since ddc647a.
AI assistance: Codex helped investigate the failure, prepare this report, and test a fix.
Activity
pythongh-159858: Add NEWS for email memoryview payload fix