DeprecationWarning is now silent by default.

This was originally suggested by Guido, discussed on the stdlib-sig mailing
list, and given the OK by Guido directly to me. What this change essentially
means is that Python has taken a policy of silencing warnings that are only
of interest to developers by default. This should prevent users from seeing
warnings which are triggered by an application being run against a new
interpreter before the app developer has a chance to update their code.

Closes issue #7319. Thanks to Antoine Pitrou, Ezio Melotti, and Brian Curtin
for helping with the issue.
This commit is contained in:
Brett Cannon 2010-01-10 02:56:19 +00:00
parent 3ad57e2625
commit 6fdd3dcb6a
6 changed files with 65 additions and 31 deletions

View file

@ -309,6 +309,7 @@ class ExceptionTests(unittest.TestCase):
# BaseException.__init__ triggers a deprecation warning.
exc = BaseException("foo")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('default')
self.assertEquals(exc.message, "foo")
self.assertEquals(len(w), 1)
self.assertEquals(w[0].category, DeprecationWarning)