From: Brett Cannon Date: Sat, 16 Aug 2008 21:47:07 +0000 (+0000) Subject: Silence the DeprecationWarning raised by importing mimetools in BaseHTTPServer. X-Git-Tag: v2.6b3~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=abe423ed2cbf0ee118f6d060890258c2898fea1d;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py index 5f2d558b689f..0a6381e422d7 100644 --- a/Lib/BaseHTTPServer.py +++ b/Lib/BaseHTTPServer.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index 0a16e8f89e2d..53158d17de31 100644 --- 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.