]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Silence the DeprecationWarning of rfc822 triggered by its importation in
authorBrett Cannon <bcannon@gmail.com>
Thu, 14 Aug 2008 05:00:03 +0000 (05:00 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 14 Aug 2008 05:00:03 +0000 (05:00 +0000)
mimetools.

This has an unfortunate side-effect of potentially not letting any warning
about rfc822's deprecation be seen by user-visible code if rfc822 is not
imported before mimetools. This is because modules are cached in sys.modules
and thus do not have their deprecation triggered more than once. But this
silencing would have happened by other code that silences the use of mimetools
or rfc822 anyway in the stdlib or user code, and thus seems justified to be
done here.

Lib/mimetools.py
Misc/NEWS

index 02963b55548de44f582f73364420129666dbce57..097eda4a75bd2fcbd4fef71a6c6e223594a6094c 100644 (file)
@@ -2,8 +2,12 @@
 
 
 import os
-import rfc822
 import tempfile
+from test.test_support import catch_warning
+from warnings import filterwarnings
+with catch_warning(record=False):
+    filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning)
+    import rfc822
 
 from warnings import warnpy3k
 warnpy3k("in 3.x, mimetools has been removed in favor of the email package",
index 0a66c78f3d6cd8e9fcb01b7bf6556c910296f588..586aa7c18e4ad7bde024ddcda0f05b5696759cb3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,10 @@ Core and Builtins
 Library
 -------
 
+- Silence the DeprecationWarning of rfc822 when it is imported by mimetools
+  since mimetools itself is deprecated. Because modules are cached, all
+  subsequent imports of rfc822 will not raise a visible DeprecationWarning.
+
 - Issue #3134: shutil referenced undefined WindowsError symbol.
 
 - Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to