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
Regression on initialization and new non-deterministic behavior issue in mimetypes #93417
Comments
Thanks for pinging me. I'll share what I know and can remember. The original bug regarded the non-deterministic behavior of the guess_extension method/function. It would return different answers upon different executions of the python interpreter and import of the mimetypes module. I suggest reading through all of https://bugs.python.org/issue4963 as it is very informative as to the discussion and approaches to a solution that were kicked around. The change you've fingered is related to this comment by me in that issue:
That comment is referring to R. David Murray's comment in that issue: https://bugs.python.org/issue4963#msg108934 It's worth reading that comment carefully and in its entirety to understand how the change to init() tried to walk a very fine line. I think this current issue is a result of that analysis and my fix related to it missing the use case where files is definitely not meant to be additive - it should be the only thing loaded. In terms of a workaround, I think the easiest thing that should work is:
Perhaps a longer-term fix would be to add a boolean argument to init() that controls whether or not knownfiles are used additively. Just my $0.02. |
Thanks for your detailed comment @davidkhess and thanks for opening the report @pombredanne. From R. David Murray's analysis in the original issue:
I'm not clear exactly what was meant by "additive", in this context. However, an examination of the I believe his analysis was perhaps referring to calling Regardless of the validity of this point of analysis, the fact remains that the current behaviour of mimetypes.init (since Python 3.7) is to load from the knownfiles as well as the files specified, and so Hyrum's Law would suggest that to put the behavior back as it was will inconvenience someone. Perhaps as a first step we could update the docstring to clearly mark that the behaviour changed between Python 3.6 and 3.7, so people that must maintain supporting for multiple versions can be aware of the difference. |
pombredanne commentedJun 1, 2022
•
edited
Bug report
Mimetypes should NOT include defaults when initialized with file(s)
This is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess #3062
I reported the issue in https://bugs.python.org/issue4963#msg384730 :
See also this thread 9fc720e#r45794801
@pombredanne
pombredanne on Jan 9, 2021 Contributor
@adeadman
adeadman 2 hours ago
@pombredanne
pombredanne 1 hour ago Contributor
And @adeadman also posted in #3062 (comment)
The text was updated successfully, but these errors were encountered: