-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-45639: Add webp and avif image formats to mimetypes #29259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
I actually signed the CLA. |
wepb is already added in #23034 (and with proper alpha sorting in the list) |
I saw the other PR, but it's not merged yet. The addition in the commit in this PR is sorted by mime type as requested in comment in the file. |
This PR is stale because it has been open for 30 days with no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed these are not new and should be added but could you add to test Lib/test/test_mimetypes.py please?
Thank you. I'll add the test. |
On second thoughts, one ticket and one PR to add both types is fine. |
I added the test. |
Can you add a news note on this model: https://github.com/python/cpython/pull/24917/files#diff-068155607fe32979f71408456e0f3163740897c21e6b6da80c45ec59cc660424 You can use https://blurb-it.herokuapp.com/ or |
If |
I think I added the news entry. Thanks for the guidance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, and sorry this was left hanging for so long! We still have a few days until the 3.11 feature freeze, and I'd love to get this in.
A few small things:
- You'll need to resign the CLA with our new process
- As @TeamSpen210 says, webp is nonstandard and should be in the
common_types
list. - The docs build is failing because the blurb is missing a trailing newline.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @JelleZijlstra: please review the changes made to this pull request. |
@kixorz thanks for the change! The tests are failing now, I think webp needs to move elsewhere in the test suite because it's not recognized by default. |
I believe I fixed the tests. |
Lib/test/test_mimetypes.py
Outdated
@@ -95,13 +95,16 @@ def test_non_standard_types(self): | |||
eq = self.assertEqual | |||
# First try strict | |||
eq(self.db.guess_type('foo.xul', strict=True), (None, None)) | |||
eq(self.db.guess_type('foo.xul', strict=True), (None, None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated
eq(self.db.guess_type('foo.xul', strict=True), (None, None)) |
Thanks for checking it. Sorry, I missed it. Should be fine now. |
Thanks for merging my changes! |
Changes were performed on integration and core. Resources: - https://www.iana.org/assignments/media-types/media-types.xhtml webp is still not listed there - python/cpython#29259 was merged 3 days ago
It seems that support for detecting the mimetype of webp file formats was added to pythons mimetype module in the python3.11 release [1], as result we skip the webp media test. The skipping is done via a conditional so will automatically run once we update to python3.11 without having to change anything. We also add a few extra comments around using a more robust file type detection method (like libmagic), there are some links for reading when the time comes to fix this, its not very pressing atm. [1] python/cpython#29259 (review)
It seems that support for detecting the mimetype of webp file formats was added to pythons mimetype module in the python3.11 release [1], as result we skip the webp media test. The skipping is done via a conditional so will automatically run once we update to python3.11 without having to change anything. We also separate gif tests from webp tests by adding a new test that uses a a gif with a `.gif` extension instead of the previous `.webp` extension. We also add a few extra comments around using a more robust file type detection method (like libmagic), there are some links for reading when the time comes to fix this, its not very pressing atm. [1] python/cpython#29259 (review)
It seems that support for detecting the mimetype of webp file formats was added to pythons mimetype module in the python3.11 release [1], as result we skip the webp media test. The skipping is done via a conditional so will automatically run once we update to python3.11 without having to change anything. We also separate gif tests from webp tests by adding a new test that uses a a gif with a `.gif` extension instead of the previous `.webp` extension. We also add a few extra comments around using a more robust file type detection method (like libmagic), there are some links for reading when the time comes to fix this, its not very pressing atm. [1] python/cpython#29259 (review)
Modern image types webp and avif are not recognized by the mimetypes module.
Problem: Many tools are written in Python and running on macOS. Good example is the AWS CLI. Running commands like "s3 sync" will save files with .webp and .avif extensions with incorrect "binary/octet-stream" Content-Type to S3. This creates additional problems with serving these resources over HTTP.
The webp and avif image types are supported by most browsers:
https://caniuse.com/#feat=webp
https://caniuse.com/#feat=avif
While webp is fully supported and largely used, it is not officially registered with IANA.
Avif is currently less popular, but it is fully registered with IANA.
https://www.iana.org/assignments/media-types/media-types.xhtml
Please consider the attached GitHub PR as a fix to these MIME Content-Type issues.
https://bugs.python.org/issue45639
#89802