Message216104
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. |
|
Date |
User |
Action |
Args |
2014-04-14 16:08:18 | a.badger | set | recipients:
+ a.badger, barry, terry.reedy, pitrou, wichert, r.david.murray, siona, l0nwlf |
2014-04-14 16:08:18 | a.badger | set | messageid: <1397491698.31.0.403471422154.issue4963@psf.upfronthosting.co.za> |
2014-04-14 16:08:18 | a.badger | link | issue4963 messages |
2014-04-14 16:08:17 | a.badger | create | |
|