
report at bugs
Aug 11, 2013, 12:43 PM
Post #2 of 4
(10 views)
Permalink
|
|
[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings
[In reply to]
|
|
Ben Hoyt added the comment: Thanks, Tim! Works for me! A couple of code review comments: 1) On 2.7, guess_type(s)[0] is a byte string as usual if the type doesn't exist in the registry, but it's a unicode string if it came from the registry. Seems like it should be a byte string in all cases (the mime type can only be ASCII char). I would say .encode('ascii') and if it raises UnicodeError, ignore that key. 2) Would 'subkeyname[0] == "."' be better as subkeyname.startswith(".")? More idiomatic, and won't bomb out if subkeyname is zero length (though that probably can't happen). Relatedly, "not subkeyname.startswith()" with an early-continue would avoid an indent and is what the rest of the code does. 3) I believe the default_encoding variable is not needed anymore. That was used in the old registry code. 4) Super-minor: "raises EnvironmentError" would be the Pythonic way to say "throws EnvironmentError". 5) Would it be worth adding a test for 'foo.png' as well, as that was another super-common type that was wrong? ---------- _______________________________________ Python tracker <report [at] bugs> <http://bugs.python.org/issue15207> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
|