]> granicus.if.org Git - python/commitdiff
fix a silly problem of caching gone wrong #5401
authorBenjamin Peterson <benjamin@python.org>
Mon, 2 Mar 2009 03:35:12 +0000 (03:35 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 2 Mar 2009 03:35:12 +0000 (03:35 +0000)
Lib/mimetypes.py
Misc/NEWS

index fc0108b1b18b83e8441cff22e11532d8cd35d24f..6212e784194c5edee2ae5e132ff5843e87fcdb5d 100644 (file)
@@ -237,7 +237,8 @@ def guess_type(url, strict=True):
     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 @@ def guess_all_extensions(type, strict=True):
     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 @@ def guess_extension(type, strict=True):
     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 @@ def add_type(type, ext, strict=True):
     list of standard types, else to the list of non-standard
     types.
     """
-    init()
+    if not inited:
+        init()
     return add_type(type, ext, strict)
 
 
index 36567f73d5efff921c9025d557d74c719e6e8c21..49a38856730f21cd9ec60c7402ddd2d7b101bd50 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -166,6 +166,9 @@ Core and Builtins
 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)