This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author benhoyt
Recipients barry, benhoyt, brian.curtin, dlchambers, ggenellina, ishimoto, lemburg, pitrou, r.david.murray, sayap, terry.reedy, tim.golden
Date 2013-08-11.19:43:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376250183.46.0.275892523503.issue15207@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2013-08-11 19:43:03benhoytsetrecipients: + benhoyt, lemburg, barry, terry.reedy, ishimoto, ggenellina, pitrou, tim.golden, sayap, r.david.murray, brian.curtin, dlchambers
2013-08-11 19:43:03benhoytsetmessageid: <1376250183.46.0.275892523503.issue15207@psf.upfronthosting.co.za>
2013-08-11 19:43:03benhoytlinkissue15207 messages
2013-08-11 19:43:03benhoytcreate