[Python-checkins] r70086 - in python/trunk: Lib/mimetypes.py Misc/NEWS

benjamin.peterson python-checkins at python.org
Mon Mar 2 04:35:13 CET 2009


Author: benjamin.peterson
Date: Mon Mar  2 04:35:12 2009
New Revision: 70086

Log:
fix a silly problem of caching gone wrong #5401

Modified:
   python/trunk/Lib/mimetypes.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/mimetypes.py
==============================================================================
--- python/trunk/Lib/mimetypes.py	(original)
+++ python/trunk/Lib/mimetypes.py	Mon Mar  2 04:35:12 2009
@@ -237,7 +237,8 @@
     Optional `strict' argument when false adds a bunch of commonly found, but
     non-standard types.
     """
-    init()
+    if not inited:
+        init()
     return guess_type(url, strict)
 
 
@@ -254,7 +255,8 @@
     Optional `strict' argument when false adds a bunch of commonly found,
     but non-standard types.
     """
-    init()
+    if not inited:
+        init()
     return guess_all_extensions(type, strict)
 
 def guess_extension(type, strict=True):
@@ -269,7 +271,8 @@
     Optional `strict' argument when false adds a bunch of commonly found,
     but non-standard types.
     """
-    init()
+    if not inited:
+        init()
     return guess_extension(type, strict)
 
 def add_type(type, ext, strict=True):
@@ -284,7 +287,8 @@
     list of standard types, else to the list of non-standard
     types.
     """
-    init()
+    if not inited:
+        init()
     return add_type(type, ext, strict)
 
 

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Mar  2 04:35:12 2009
@@ -166,6 +166,9 @@
 Library
 -------
 
+- Issue #5401: Fixed a performance problem in mimetypes when ``from mimetypes
+  import guess_extension`` was used.
+
 - Issue #1733986: Fixed mmap crash in accessing elements of second map object
   with same tagname but larger size than first map. (Windows)
 


More information about the Python-checkins mailing list