Possible bug with stability of mimetypes.guess_* function output

Asaf Las roegltd at gmail.com
Sat Feb 8 11:59:58 CET 2014


On Saturday, February 8, 2014 10:39:06 AM UTC+2, Peter Otten wrote:
> Asaf Las wrote:
> > On Saturday, February 8, 2014 9:51:48 AM UTC+2, Peter Otten wrote:
> >> At least the mimetypes already defined in the module could easily produce
> >> the same guessed extension consistently.
> > imho one workaround for OP could be to supply own map file in init() thus
> > ensure unambiguous mapping across every platform and distribution. guess
> > some libraries already doing that. or write wrapper and process
> > all_guesses to eliminate ambiguity up to needed requirement.
> > that is in case if bug request will be rejected.
> 
> You also have to set mimetypes.types_map and mimetypes.common_types to an 
> empty dict (or an OrderedDict).

Hmmm, yes. then the quickest workaround is to get all guesses list then
sort it and use the one at index 0.



More information about the Python-list mailing list