diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-01-14 20:00:28 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-01-14 20:00:28 (GMT) |
commit | 3ffa43db4892d3a836c63911c5a13a8be5670fa5 (patch) | |
tree | 5b28b121ee874b1a7341b0cf50fdcec777919e7b /Lib | |
parent | efdddd3370fc646836b6113247159846734fc129 (diff) | |
download | cpython-3ffa43db4892d3a836c63911c5a13a8be5670fa5.zip cpython-3ffa43db4892d3a836c63911c5a13a8be5670fa5.tar.gz cpython-3ffa43db4892d3a836c63911c5a13a8be5670fa5.tar.bz2 |
The silencing of DeprecationWarning was not taking -3 into consideration. Since
Py3K warnings are DeprecationWarning by default this was causing -3 to
essentially be a no-op. Now DeprecationWarning is only silenced if -3 is not
used.
Closes issue #7700. Thanks Ezio Melotti and Florent Xicluna for patch help.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/warnings.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index a88e7ba..70b3d43 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -383,8 +383,11 @@ except ImportError: # Module initialization _processoptions(sys.warnoptions) if not _warnings_defaults: - for cls in (DeprecationWarning, PendingDeprecationWarning, ImportWarning): - simplefilter("ignore", category=cls, append=True) + silence = [ImportWarning, PendingDeprecationWarning] + if not sys.py3kwarning: # Don't silence DeprecationWarning if -3 was used. + silence.append(DeprecationWarning) + for cls in silence: + simplefilter("ignore", category=cls) bytes_warning = sys.flags.bytes_warning if bytes_warning > 1: bytes_action = "error" |