-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-4963: Fix for initialization and non-deterministic behavior issues in mimetypes #3062
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
Doc/library/mimetypes.rst
Outdated
@@ -88,6 +88,10 @@ behavior of the module. | |||
Specifying an empty list for *files* will prevent the system defaults from | |||
being applied: only the well-known values will be present from a built-in list. | |||
|
|||
If *files* is not specified or is ``None`` the internal data structure is completely |
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.
Since files
is already set to None
you don't have to explicitly call out what happens if you don't specify an argument.
Bring in the new .json entry from master.
I see a new check. Should I write a news entry for this? Or will the committer? |
@davidkhess It's easier for us if you create the news entry because if a core dev decides to merge this they can edit the file easily through GitHub's web UI while having to add a file is much more burdensome. |
News entry added. |
@bitdancer, anything I can do to help this along? |
1 similar comment
@bitdancer, anything I can do to help this along? |
@brettcannon @bitdancer, anything I can do to help this along? I'm willing to resolve the conflict but I don't want to waste my time if this PR is never going to be merged. |
Unfortunately I don't know this module well enough to feel comfortable reviewing it. I would try pinging the issue to ask if someone could review it. |
Pinged. |
Lib/mimetypes.py
Outdated
@@ -32,6 +32,8 @@ | |||
except ImportError: | |||
_winreg = None | |||
|
|||
from collections import OrderedDict |
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 no longer needed in 3.7+.
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.
Should I remove all usage of OrderedDict from the PR and let others add it back for back porting it to 2.7? Or should I do something like set OrderedDict = dict if Python version >= 3.7?
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.
The order of the items in the list is a critical part of the fix - I'd vote for retaining the explicit use of OrderedDict.
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.
Adding OrderedDict makes this PR more complex, and the resulting code clumsy, and this is absolutely unneeded in 3.7+. I think it would be better to merge a simple fix into master and 3.7, and prepare more complex backport for 3.6.
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.
Since 3.6 is only receiving security fixes, there's no need to worry about the backport to 3.6 anymore. So, you can remove the OrderedDict as this will only be in 3.7 and 3.8.
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.
Please resolve the merge conflict
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 |
Lib/mimetypes.py
Outdated
@@ -32,6 +32,8 @@ | |||
except ImportError: | |||
_winreg = None | |||
|
|||
from collections import OrderedDict |
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.
The order of the items in the list is a critical part of the fix - I'd vote for retaining the explicit use of OrderedDict.
The merge conflict does need to be fixed, and it looks like it'll be a bit of work to figure out exactly what needs merging. |
@davidkhess, you can remove the OrderedDict as this point since this won't be applied to 3.6. Since this was close to being merged before, pending the discussion of the OrderedDict, if you fix the merge conflict and remove the OrderedDict, I think this will be able to be merged. Thank you for your contribution and for your patience. 🙂 |
@davidkhess If you allow me to push on your branch I can help to get this merged |
I'm making the requested changes now. |
@serhiy-storchaka and @zooba, the merge conflicts have been resolved. I know this was approved last year, but I wanted to make sure you were still OK with it before merging. Thanks! |
Thanks @davidkhess for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry @davidkhess and @zooba, I had trouble checking out the |
GH-14375 is a backport of this pull request to the 3.8 branch. |
This change has resulted in a difference in behaviour from previous versions of Python in that even when specifying Unfortunately this change wasn't documented in the changelog either, nor in the docstring comments, so it can only be found by examining the commit history for the code in cpython. Would it be appropriate to add another kwarg to |
@adeadman posted a message inline as a reply to mine at 9fc720e#r45794801 In essence this fixe was supposed to bring in a deterministic behaviour and actually had the complete opposite effect. I still consider this a regression. I stopped using mimetypes for now as it is useless as it is now. |
Could you please open a new bug report? Comments on closed PRs tend to get lost. |
Tracked in:
https://bugs.python.org/issue4963
In particular, here's my thoughts on it which led to this PR:
https://bugs.python.org/msg293626
https://bugs.python.org/issue4963