Author a.badger
Recipients a.badger, barry, l0nwlf, pitrou, r.david.murray, siona, terry.reedy, wichert
Date 2014-04-14.16:08:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397491698.31.0.403471422154.issue4963@psf.upfronthosting.co.za>
In-reply-to
Content
Took a look at this and was able to reproduce it on Fedora Linux 20 and current cpython head.  It is somewhat random though.  I'm able to get reasonably consistent failures using image/jpeg and iterating the test case about 20 times.

Additionally, it looks like the data structure that mimetypes.guess_extensions() is reading its extensions from is a list so it doesn't have to do with dictionary sort order.  It has something to do with the way the extensions are read in from the files and then given to add_type().

Talking to r.david.murray I think that this particular problem can be solved by simply sorting the list of extensions prior to guess_extension taking the first extension off of the list.

The question of what to do when the first extension in the list isn't the best extension should be resolved in Issue1043134.

I'll attach a patch with test case for this problem.
History
Date User Action Args
2014-04-14 16:08:18a.badgersetrecipients: + a.badger, barry, terry.reedy, pitrou, wichert, r.david.murray, siona, l0nwlf
2014-04-14 16:08:18a.badgersetmessageid: <1397491698.31.0.403471422154.issue4963@psf.upfronthosting.co.za>
2014-04-14 16:08:18a.badgerlinkissue4963 messages
2014-04-14 16:08:17a.badgercreate