mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-91217: deprecate imghdr (#91461)
* Deprecate imghdr Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> * Update Doc/whatsnew/3.11.rst Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> * Inline `imghdr` into `email.mime.image` Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Barry Warsaw <barry@python.org>
This commit is contained in:
parent
dfbc792a4b
commit
3fc57e8f6f
8 changed files with 128 additions and 23 deletions
|
@ -1,9 +1,6 @@
|
|||
# Import smtplib for the actual sending function
|
||||
import smtplib
|
||||
|
||||
# And imghdr to find the types of our images
|
||||
import imghdr
|
||||
|
||||
# Here are the email package modules we'll need
|
||||
from email.message import EmailMessage
|
||||
|
||||
|
@ -22,7 +19,7 @@ for file in pngfiles:
|
|||
with open(file, 'rb') as fp:
|
||||
img_data = fp.read()
|
||||
msg.add_attachment(img_data, maintype='image',
|
||||
subtype=imghdr.what(None, img_data))
|
||||
subtype='jpeg')
|
||||
|
||||
# Send the email via our own SMTP server.
|
||||
with smtplib.SMTP('localhost') as s:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue