Possible bug with stability of mimetypes.guess_* function output

Asaf Las roegltd at gmail.com
Fri Feb 7 21:25:52 CET 2014

On Friday, February 7, 2014 9:40:06 PM UTC+2, Peter Otten wrote:
> As Johannes mentioned, this depends on the hash seed:
> $ PYTHONHASHSEED=0 python3 -c 'print({".htm", ".html", ".shtml"}.pop())'
> .html
> $ PYTHONHASHSEED=1 python3 -c 'print({".htm", ".html", ".shtml"}.pop())'
> .htm
> $ PYTHONHASHSEED=2 python3 -c 'print({".htm", ".html", ".shtml"}.pop())'
> .shtml
> You never see ".shtml" as the guessed extension because it is not in the 
> original mimetypes.types_map dict, but instead programmaticaly read from a 
> file like /etc/mime.types and then added to a list of extensions.
as there are bunch of files in mimetypes.py the only repeatability could 
be achieved on particular machine level.


More information about the Python-list mailing list