| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
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.) |
Sorry, something went wrong.
|
As said in https://bugs.python.org/issue31040, please use startswith instead of find. There is one case where it works without a dot: >>> mimetypes.add_type('empty', '')
>>> mimetypes.guess_type('')
('empty', None)
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. |
Sorry, something went wrong.
|
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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. |
Sorry, something went wrong.
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.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @JulienPalard: please review the changes made to this pull request. |
Sorry, something went wrong.
|
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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. And if you don't make the requested changes, you will be put in the comfy chair! |
Sorry, something went wrong.
|
IMO, this is a backwards-incompatible change and should be deprecated with a warning, and documented. (For example, if add_type is fed from a data file, this PR can change a relatively harmless data-entry error into a hard failure. Or someone could use types_map directly.) |
Sorry, something went wrong.
|
Thanks, please see #128638 to deprecate it first, and I've marked this as a draft until it's ready for merge. |
Sorry, something went wrong.
It was deprecated and scheduled for 3.16, so it's time! |
Sorry, something went wrong.
Documentation build overview3 files changed ± library/mimetypes.html ± whatsnew/3.16.html ± whatsnew/changelog.html |
Sorry, something went wrong.
|
|
||
| .. function:: add_type(type, ext, strict=True) | ||
|
|
||
| Add a mapping from the MIME type *type* to the extension *ext*. When the |
There was a problem hiding this comment.
This should have the same "Valid extensions start with a '.' or are empty." note IMO, but it wasn't updated before?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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