Skip to content

email.policy.compat32 does not work as policy for email.message.MIMEPart #133315

Open
@dkg

Description

@dkg

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions