https://github.com/python/cpython/commit/4cec0b510bfb779bc683825aa03961642b1e1549 commit: 4cec0b510bfb779bc683825aa03961642b1e1549 branch: main author: Hugo van Kemenade <1324225+hug...@users.noreply.github.com> committer: hugovk <1324225+hug...@users.noreply.github.com> date: 2025-04-28T15:30:35Z summary:
gh-129965: Add more missing MIME types (#132845) files: A Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst M Doc/whatsnew/3.14.rst M Lib/mimetypes.py M Lib/test/test_mimetypes.py diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 82ef636778183b..9b28d7b6247309 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1001,9 +1001,22 @@ mimetypes * :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi`` and for ``.wav`` to ``audio/vnd.wave`` - * :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``)) + * :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``) * :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``) + * :rfc:`6713`: Add gzip ``application/gzip`` (``.gz``) * :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``) + * Add 7z ``application/x-7z-compressed`` (``.7z``) + * Add Android Package ``application/vnd.android.package-archive`` (``.apk``) + when not strict + * Add deb ``application/x-debian-package`` (``.deb``) + * Add glTF binary ``model/gltf-binary`` (``.glb``) + * Add glTF JSON/ASCII ``model/gltf+json`` (``.gltf``) + * Add M4V ``video/x-m4v`` (``.m4v``) + * Add PHP ``application/x-httpd-php`` (``.php``) + * Add RAR ``application/vnd.rar`` (``.rar``) + * Add RPM ``application/x-rpm`` (``.rpm``) + * Add STL ``model/stl`` (``.stl``) + * Add Windows Media Video ``video/x-ms-wmv`` (``.wmv``) * De facto: Add WebM ``audio/webm`` (``.weba``) * `ECMA-376 <https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__: diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index e93e1d5a03a454..b5a1b8da2638e0 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -478,6 +478,7 @@ def _default_mime_types(): '.js' : 'text/javascript', '.mjs' : 'text/javascript', '.epub' : 'application/epub+zip', + '.gz' : 'application/gzip', '.json' : 'application/json', '.webmanifest': 'application/manifest+json', '.doc' : 'application/msword', @@ -517,10 +518,13 @@ def _default_mime_types(): '.pptx' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation', '.xlsx' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + '.rar' : 'application/vnd.rar', '.wasm' : 'application/wasm', + '.7z' : 'application/x-7z-compressed', '.bcpio' : 'application/x-bcpio', '.cpio' : 'application/x-cpio', '.csh' : 'application/x-csh', + '.deb' : 'application/x-debian-package', '.dvi' : 'application/x-dvi', '.gtar' : 'application/x-gtar', '.hdf' : 'application/x-hdf', @@ -530,10 +534,12 @@ def _default_mime_types(): '.cdf' : 'application/x-netcdf', '.nc' : 'application/x-netcdf', '.p12' : 'application/x-pkcs12', + '.php' : 'application/x-httpd-php', '.pfx' : 'application/x-pkcs12', '.ram' : 'application/x-pn-realaudio', '.pyc' : 'application/x-python-code', '.pyo' : 'application/x-python-code', + '.rpm' : 'application/x-rpm', '.sh' : 'application/x-sh', '.shar' : 'application/x-shar', '.swf' : 'application/x-shockwave-flash', @@ -623,6 +629,9 @@ def _default_mime_types(): '.mht' : 'message/rfc822', '.mhtml' : 'message/rfc822', '.nws' : 'message/rfc822', + '.gltf' : 'model/gltf+json', + '.glb' : 'model/gltf-binary', + '.stl' : 'model/stl', '.css' : 'text/css', '.csv' : 'text/csv', '.html' : 'text/html', @@ -661,6 +670,8 @@ def _default_mime_types(): '.qt' : 'video/quicktime', '.webm' : 'video/webm', '.avi' : 'video/vnd.avi', + '.m4v' : 'video/x-m4v', + '.wmv' : 'video/x-ms-wmv', '.movie' : 'video/x-sgi-movie', } @@ -670,6 +681,7 @@ def _default_mime_types(): # Please sort these too common_types = _common_types_default = { '.rtf' : 'application/rtf', + '.apk' : 'application/vnd.android.package-archive', '.midi': 'audio/midi', '.mid' : 'audio/midi', '.jpg' : 'image/jpg', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index b9197069a08a88..dad5dbde7cd783 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -7,7 +7,6 @@ from platform import win32_edition from test import support from test.support import os_helper -from test.support.script_helper import run_python_until_end try: import _winapi @@ -227,6 +226,7 @@ def check_extensions(): for mime_type, ext in ( ("application/epub+zip", ".epub"), ("application/octet-stream", ".bin"), + ("application/gzip", ".gz"), ("application/ogg", ".ogx"), ("application/postscript", ".ps"), ("application/vnd.apple.mpegurl", ".m3u"), @@ -240,6 +240,11 @@ def check_extensions(): ("application/vnd.openxmlformats-officedocument.presentationml.presentation", ".pptx"), ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"), ("application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"), + ("application/vnd.rar", ".rar"), + ("application/x-7z-compressed", ".7z"), + ("application/x-debian-package", ".deb"), + ("application/x-httpd-php", ".php"), + ("application/x-rpm", ".rpm"), ("application/x-texinfo", ".texi"), ("application/x-troff", ".roff"), ("application/xml", ".xsl"), @@ -268,6 +273,9 @@ def check_extensions(): ("image/webp", ".webp"), ("image/wmf", ".wmf"), ("message/rfc822", ".eml"), + ("model/gltf+json", ".gltf"), + ("model/gltf-binary", ".glb"), + ("model/stl", ".stl"), ("text/html", ".html"), ("text/plain", ".txt"), ("text/rtf", ".rtf"), @@ -278,6 +286,8 @@ def check_extensions(): ("video/ogg", ".ogv"), ("video/quicktime", ".mov"), ("video/vnd.avi", ".avi"), + ("video/x-m4v", ".m4v"), + ("video/x-ms-wmv", ".wmv"), ): with self.subTest(mime_type=mime_type, ext=ext): self.assertEqual(mimetypes.guess_extension(mime_type), ext) diff --git a/Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst b/Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst new file mode 100644 index 00000000000000..e693a2c0ffdd18 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst @@ -0,0 +1,3 @@ +Add MIME types for ``.7z``, ``.apk``, ``.deb``, ``.glb``, ``.gltf``, +``.gz``, ``.m4v``, ``.php``, ``.rar``, ``.rpm``, ``.stl`` and ``.wmv``. +Patch by Hugo van Kemenade. _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com