https://github.com/python/cpython/commit/b905fad83819ec9102ecfb97e3d8ab0aaddd9784
commit: b905fad83819ec9102ecfb97e3d8ab0aaddd9784
branch: main
author: Nachtalb <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-01-31T17:33:46+02:00
summary:
gh-111741: Recognise image/webp as a standard format in the mimetypes module
(GH-111742)
Previously it was supported as a non-standard type.
files:
A Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst
M Lib/mimetypes.py
M Lib/test/test_mimetypes.py
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 37228de4828de5..51b99701c9d727 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -528,6 +528,7 @@ def _default_mime_types():
'.tiff' : 'image/tiff',
'.tif' : 'image/tiff',
'.ico' : 'image/vnd.microsoft.icon',
+ '.webp' : 'image/webp',
'.ras' : 'image/x-cmu-raster',
'.pnm' : 'image/x-portable-anymap',
'.pbm' : 'image/x-portable-bitmap',
@@ -587,7 +588,6 @@ def _default_mime_types():
'.pict': 'image/pict',
'.pct' : 'image/pict',
'.pic' : 'image/pict',
- '.webp': 'image/webp',
'.xul' : 'text/xul',
}
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py
index d64aee71fc48b1..01bba0ac2eed5a 100644
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -96,14 +96,12 @@ def test_non_standard_types(self):
# First try strict
eq(self.db.guess_type('foo.xul', strict=True), (None, None))
eq(self.db.guess_extension('image/jpg', strict=True), None)
- eq(self.db.guess_extension('image/webp', strict=True), None)
# And then non-strict
eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None))
eq(self.db.guess_type('foo.XUL', strict=False), ('text/xul', None))
eq(self.db.guess_type('foo.invalid', strict=False), (None, None))
eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')
eq(self.db.guess_extension('image/JPG', strict=False), '.jpg')
- eq(self.db.guess_extension('image/webp', strict=False), '.webp')
def test_filename_with_url_delimiters(self):
# bpo-38449: URL delimiters cases should be handled also.
@@ -183,6 +181,7 @@ def check_extensions():
self.assertEqual(mimetypes.guess_extension('application/xml'),
'.xsl')
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif')
+ self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp')
self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg')
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
self.assertEqual(mimetypes.guess_extension('message/rfc822'),
'.eml')
diff --git
a/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst
b/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst
new file mode 100644
index 00000000000000..e43f93a270ce9c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst
@@ -0,0 +1 @@
+Recognise ``image/webp`` as a standard format in the :mod:`mimetypes` module.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]