Skip to content

Commit

Permalink
pythongh-111741: Recognise image/webp as a standard format in the mim…
Browse files Browse the repository at this point in the history
…etypes module (pythonGH-111742)

Previously it was supported as a non-standard type.
  • Loading branch information
Nachtalb committed Jan 31, 2024
1 parent 765b9ce commit b905fad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -587,7 +588,6 @@ def _default_mime_types():
'.pict': 'image/pict',
'.pct' : 'image/pict',
'.pic' : 'image/pict',
'.webp': 'image/webp',
'.xul' : 'text/xul',
}

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Recognise ``image/webp`` as a standard format in the :mod:`mimetypes` module.

0 comments on commit b905fad

Please sign in to comment.