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

Andrew McNabb amcnabb at mcnabbs.org
Sat Aug 1 00:01:10 CEST 2009


On Fri, Jul 31, 2009 at 09:16:02PM +0000, 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.

For the other stuff, you seem to have some very good points.  I'm sure a
patch would be welcome.

-- 
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868


More information about the Python-Dev mailing list