[issue4969] mimetypes on Windows should read MIME database from registry (w/patch)

Frank Hamand report at bugs.python.org
Sat Mar 23 13:05:36 CET 2013


Frank Hamand added the comment:

>From msg172531 in issue10551:

"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

----------
nosy: +shawabawa
versions: +Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4969>
_______________________________________


More information about the Python-bugs-list mailing list