[Python-Dev] standard library mimetypes module pathologically broken?

Jacob Rus jacobolus at gmail.com
Sat Aug 1 04:53:02 CEST 2009


Andrew McNabb wrote:
> Jacob Rus wrote:
>>   * The operation is crazy: It defines a MimeTypes class which 
>>     actually stores the type mappings, but this class is designed to 
>>     be a singleton. The way that such a design is enforced is 
>>     through the use of the module-global 'init' function, which 
>>     makes an instance of the class, and then maps all of the 
>>     functions in the module global namespace to instance methods. 
>>     But confusingly, all such functions are also defined 
>>     independently of the init function, with definitions such as:
>>   
>>         def guess_type(url, strict=True):
>>             if not inited:
>>                 init()
>>             return guess_type(url, strict)
> 
> I can't speak for any of your other complaints, but I know that this
> weird init stuff is fixed in trunk.

Actually, this fix changes the semantics of the code quite
substantially (not in any way that is incompatible with the
extremely vague documentation, but in a way that might break any
code that relies on the Python <=2.6 behavior). If such a change is
okay, then we can do quite a bit of implementation change under
these new semantics.

Cheers,
Jacob Rus



More information about the Python-Dev mailing list