-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
mimetypes on Windows should read MIME database from registry (w/patch) #49219
Comments
The mimetypes module has a built-in default database, and, in addition, |
A couple of points:
|
A new patch taking into account M. Pitrou comments:
|
Thank you, the patch looks ok to me. |
Committed in r76306 and r76307, closing. |
"You see, "MIME\Database\Content Type" in the Windows registry is a mime type -> file extension mapping, *not the other way around*. But read_windows_registry() tries to use it as a file extension -> mime type mapping, and bad things happen, because there are multiple mime types for certain file extensions." This "enhancement" has basically broken the mimetypes module on windows, e.g. On my system (windows 7 64 bit, python 3.3)
>>> mimetypes.guess_type('foo.png')
('image/x-png', None)
>>> mimetypes.guess_type('foo.jpg')
('image/pjpeg', None) The expected results are image/png and image/jpeg I'm having to work around this by calling mimetypes.init(files=[]) immediately after importing mimetypes to prevent it reading from the registry |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: