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.
This commit is contained in:
Brett Cannon 2010-01-14 20:00:28 +00:00
parent efdddd3370
commit 3ffa43db48
3 changed files with 25 additions and 15 deletions

View file

@ -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"