Silence the DeprecationWarning raised by importing mimetools in BaseHTTPServer.
authorBrett Cannon <bcannon@gmail.com>
Sat, 16 Aug 2008 21:47:07 +0000 (21:47 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sat, 16 Aug 2008 21:47:07 +0000 (21:47 +0000)
This does have an unfortunate side-effect of silencing the warning for all
subsequent code that imports mimetools as well since the warning is only
executed upon the first import of mimetools.

Lib/BaseHTTPServer.py
Misc/NEWS

index 5f2d558b689fb8010885f092d4131e16f2d09b54..0a6381e422d7f0bd0f605768df3fad4d3ecee5b4 100644 (file)
@@ -73,7 +73,12 @@ __all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
 import sys
 import time
 import socket # For gethostbyaddr()
-import mimetools
+from test.test_support import catch_warning
+from warnings import filterwarnings
+with catch_warning(record=False):
+    filterwarnings("ignore", ".*mimetools has been removed",
+                    DeprecationWarning)
+    import mimetools
 import SocketServer
 
 # Default error message template
index 0a16e8f89e2d19c58662b8a91f607c8b34e117a6..53158d17de31d62e766c33117b810def60ebeb27 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,9 @@ Core and Builtins
 Library
 -------
 
+- Silence the DeprecationWarning raised when importing mimetools in
+  BaseHTTPServer.
+
 - Issue #2776: fixed small issue when handling an URL with double slash
   after a 302 response in the case of not going through a proxy.