`email.mime.image.MIMEImage`'s `policy` argument doesn't take effect
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
I'm comparing the creation of two MIME parts, one using MIMEImage and one using MIMEPart, with the same policy object, which asks for max_line_length=35.
the MIMEImage does not respect the max_line_length when base64-encoding, but the MIMEPart does:
#!/usr/bin/python3
from io import BytesIO
from email.policy import EmailPolicy
from email.mime.image import MIMEImage
from email.message import MIMEPart
from PIL import Image, ImageDraw
img = Image.new('RGBA', (20,20))
d = ImageDraw.Draw(img)
d.regular_polygon((10,6,6), 3, fill='red')
d.line([(16,10), (10,16)], fill='blue', width=2)
d.line([(16,16), (10,10)], fill='blue', width=2)
b = BytesIO()
img.save(b, format='png', optimize=True)
imgbytes = b.getvalue()
policy = EmailPolicy(max_line_length=35)
f = MIMEImage(imgbytes, policy=policy)
print(f)
g = MIMEPart(policy=policy)
g.set_content(imgbytes, 'image', 'png')
print(g)
The output is:
Content-Type: image/png
MIME-Version: 1.0
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAcElEQVR42uVTOxbAMAgS739nO3Tp
Rw20dqpbfARQEjOywiwYnCtkDKnbcLk66sqlT+zt9cidkE+6KwkZsgrzfcqVMpL2jo0447gYDpeA
rk+OnJHkIhAfTPRicihAf5YJrw7vjv0ZWRWM/ulivdPf1QZ2kDD9xppd8wAAAABJRU5ErkJggg==
Content-Type: image/png
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAAABQAAAAU
CAYAAACNiR0NAAAAcElEQVR42uVTOxbA
MAgS739nO3TpRw20dqpbfARQEjOywiwY
nCtkDKnbcLk66sqlT+zt9cidkE+6KwkZ
sgrzfcqVMpL2jo0447gYDpeArk+OnJHk
IhAfTPRicihAf5YJrw7vjv0ZWRWM/uli
vdPf1QZ2kDD9xppd8wAAAABJRU5ErkJg
gg==
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-133322
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza comparando las implementaciones de email.mime.image.MIMEImage y email.message.MIMEPart, centrándote en cómo cada una utiliza la EmailPolicy proporcionada durante la codificación base64. Reproduce el ejemplo con max_line_length=35 y confirma que MIMEImage emite líneas que no son más largas de lo permitido por la policy; el PR enlazado gh-133322 indica que el trabajo ya está en curso.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100