Possible bug with stability of mimetypes.guess_* function output

Asaf Las roegltd at gmail.com
Fri Feb 7 15:25:52 EST 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.

"/etc/mime.types",
"/etc/httpd/mime.types",               
"/etc/httpd/conf/mime.types",          
"/etc/apache/mime.types",              
"/etc/apache2/mime.types",             
"/usr/local/etc/httpd/conf/mime.types",
"/usr/local/lib/netscape/mime.types",
"/usr/local/etc/httpd/conf/mime.types",
"/usr/local/etc/mime.types"



More information about the Python-list mailing list