cpython icon indicating copy to clipboard operation
cpython copied to clipboard

`email.policy.compat32` does not work as `policy` for `email.message.MIMEPart`

Open dkg opened this issue 8 months ago • 8 comments

Bug report

Bug description:

#!/usr/bin/python3

from email.message import MIMEPart
from email.policy import compat32

m = MIMEPart(policy=compat32)
m.set_content(b'\x00'*100, 'image', 'phg')

This raises the following exception:

Traceback (most recent call last):
  File "[…]/test.py", line 7, in <module>
    m.set_content(b'\x00'*100, 'image', 'phg')
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/email/message.py", line 1136, in set_content
    content_manager = self.policy.content_manager
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Compat32' object has no attribute 'content_manager'

This is with python3 3.13.3-1 on debian.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

  • gh-143307

dkg avatar May 02 '25 18:05 dkg