summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-01-10 02:56:19 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-01-10 02:56:19 (GMT)
commit6fdd3dcb6a9998dbe7b707d7a3726733cc03681a (patch)
tree35f061054f51f3beffbde6edc85657dcbbddec97 /Lib
parent3ad57e2625601701b1a98324890095f411965af3 (diff)
downloadcpython-6fdd3dcb6a9998dbe7b707d7a3726733cc03681a.zip
cpython-6fdd3dcb6a9998dbe7b707d7a3726733cc03681a.tar.gz
cpython-6fdd3dcb6a9998dbe7b707d7a3726733cc03681a.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_ascii_formatd.py2
-rw-r--r--Lib/test/test_exceptions.py1
-rw-r--r--Lib/warnings.py4
3 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_ascii_formatd.py b/Lib/test/test_ascii_formatd.py
index 5ee84fa..77759fe 100644
--- a/Lib/test/test_ascii_formatd.py
+++ b/Lib/test/test_ascii_formatd.py
@@ -4,6 +4,7 @@
import unittest
from test_support import check_warnings, run_unittest, cpython_only
+import warnings
class FormatDeprecationTests(unittest.TestCase):
@@ -17,6 +18,7 @@ class FormatDeprecationTests(unittest.TestCase):
buf = create_string_buffer(' ' * 100)
with check_warnings() as w:
+ warnings.simplefilter('default')
PyOS_ascii_formatd(byref(buf), sizeof(buf), '%+.10f',
c_double(10.0))
self.assertEqual(buf.value, '+10.0000000000')
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index a30f42b..3a2bdf5 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -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)
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 8d46cd6..a88e7ba 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -383,8 +383,8 @@ except ImportError:
# Module initialization
_processoptions(sys.warnoptions)
if not _warnings_defaults:
- simplefilter("ignore", category=PendingDeprecationWarning, append=1)
- simplefilter("ignore", category=ImportWarning, append=1)
+ for cls in (DeprecationWarning, PendingDeprecationWarning, ImportWarning):
+ simplefilter("ignore", category=cls, append=True)
bytes_warning = sys.flags.bytes_warning
if bytes_warning > 1:
bytes_action = "error"