summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2022-04-13 10:47:41 -0700
committerGitHub <noreply@github.com>2022-04-13 10:47:41 -0700
commit3fc57e8f6ff925b561b03c46bcf5bd323782c19c (patch)
treea69bfe3acdb5be3ee7ffc0536d15397a39580800 /Doc
parentdfbc792a4b1e033d6628eda463c0933aef081bbe (diff)
downloadcpython-git-3fc57e8f6ff925b561b03c46bcf5bd323782c19c.tar.gz
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>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/includes/email-mime.py5
-rw-r--r--Doc/library/email.mime.rst11
-rw-r--r--Doc/whatsnew/3.11.rst1
3 files changed, 8 insertions, 9 deletions
diff --git a/Doc/includes/email-mime.py b/Doc/includes/email-mime.py
index 6af2be0b08..c87db6a064 100644
--- a/Doc/includes/email-mime.py
+++ b/Doc/includes/email-mime.py
@@ -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:
diff --git a/Doc/library/email.mime.rst b/Doc/library/email.mime.rst
index f37f6aa28d..ab4f7bc54e 100644
--- a/Doc/library/email.mime.rst
+++ b/Doc/library/email.mime.rst
@@ -180,11 +180,12 @@ Here are the classes:
A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the
:class:`MIMEImage` class is used to create MIME message objects of major type
:mimetype:`image`. *_imagedata* is a string containing the raw image data. If
- this data can be decoded by the standard Python module :mod:`imghdr`, then the
- subtype will be automatically included in the :mailheader:`Content-Type` header.
- Otherwise you can explicitly specify the image subtype via the *_subtype*
- argument. If the minor type could not be guessed and *_subtype* was not given,
- then :exc:`TypeError` is raised.
+ this data type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm,
+ rast, xbm, bmp, webp, and exr attempted), then the subtype will be
+ automatically included in the :mailheader:`Content-Type` header. Otherwise
+ you can explicitly specify the image subtype via the *_subtype* argument.
+ If the minor type could not be guessed and *_subtype* was not given, then
+ :exc:`TypeError` is raised.
Optional *_encoder* is a callable (i.e. function) which will perform the actual
encoding of the image data for transport. This callable takes one argument,
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index d803801f27..894ec8a9d0 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -856,6 +856,7 @@ Deprecated
* :mod:`cgitb`
* :mod:`chunk`
* :mod:`crypt`
+ * :mod:`imghdr`
(Contributed by Brett Cannon in :issue:`47061`.)