[Python-checkins] r65716 - in python/trunk: Lib/BaseHTTPServer.py Misc/NEWS

brett.cannon python-checkins at python.org
Sat Aug 16 23:47:08 CEST 2008


Author: brett.cannon
Date: Sat Aug 16 23:47:07 2008
New Revision: 65716

Log:
Silence the DeprecationWarning raised by importing mimetools in BaseHTTPServer.
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.


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

Modified: python/trunk/Lib/BaseHTTPServer.py
==============================================================================
--- python/trunk/Lib/BaseHTTPServer.py	(original)
+++ python/trunk/Lib/BaseHTTPServer.py	Sat Aug 16 23:47:07 2008
@@ -73,7 +73,12 @@
 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

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Aug 16 23:47:07 2008
@@ -48,6 +48,9 @@
 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.
 


More information about the Python-checkins mailing list