Toshio Kuratomi added the comment:

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.

----------
nosy: +a.badger
Added file: http://bugs.python.org/file34821/issue4963.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4963>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to