summaryrefslogtreecommitdiffstats
path: root/Lib/mimetools.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-08-14 05:00:03 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-08-14 05:00:03 (GMT)
commitbf3157b8e03f0a661f9f90fa0ab610f03fb2ea89 (patch)
tree1d06931fa5e1e0203296ce18f9478ab92e7f5f52 /Lib/mimetools.py
parenteea8eda317ded5c519e663237c9850482c2cb06e (diff)
downloadcpython-bf3157b8e03f0a661f9f90fa0ab610f03fb2ea89.zip
cpython-bf3157b8e03f0a661f9f90fa0ab610f03fb2ea89.tar.gz
cpython-bf3157b8e03f0a661f9f90fa0ab610f03fb2ea89.tar.bz2
Silence the DeprecationWarning of rfc822 triggered by its importation in
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.
Diffstat (limited to 'Lib/mimetools.py')
-rw-r--r--Lib/mimetools.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index 02963b5..097eda4 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -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",