-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-75223: Reject undotted extensions in mimetypes.add_type #2895
base: main
Are you sure you want to change the base?
Conversation
I've opened this now to get feedback on whether this is an appropriate change to make. Does it need a warning first, before it becomes the default behaviour? (At a minimum, I would expect to need to add to documentation.) |
As said in https://bugs.python.org/issue31040, please use There is one case where it works without a dot:
And someone may have used it to distinguish between emptyness and type not found. What I propose: Emit a warning in case the ext is empty, else ValueError in case the type does not start with a dot, to ensure we're not breaking any code. |
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 |
Extensions that don't start with a dot will never be found by methods/functions that act on the registry, so we should stop users from mistakenly adding them. The one exception is the empty string extension. This could be in use to detect absent extensions, so instead of raising a ValueError we emit a warning.
b92d271
to
1485be9
Compare
I have made the requested changes; please review again. |
Thanks for making the requested changes! @JulienPalard: please review the changes made to this pull request. |
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 And if you don't make the requested changes, you will be put in the comfy chair! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
Some nits, but also the tests need updating to match the implementation change in f0c1bf7
(#2895).
Misc/NEWS.d/next/Library/2019-09-10-09-28-52.bpo-31040.VyAJS9.rst
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Dismissing my review, I've updated the PR
Extensions that don't start with a dot will never be found by
methods/functions that act on the registry, so we should stop users from
mistakenly adding them.
https://bugs.python.org/issue31040