summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-06-27 00:52:15 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-06-27 00:52:15 (GMT)
commitdb7349128faa564954554da95ce7bfb8802ff31f (patch)
tree5dbf92d7a143b344b364de942984462cc2b66ecb /Lib/test
parent429ef650b749efcade39b5f65862f546610a8191 (diff)
downloadcpython-db7349128faa564954554da95ce7bfb8802ff31f.zip
cpython-db7349128faa564954554da95ce7bfb8802ff31f.tar.gz
cpython-db7349128faa564954554da95ce7bfb8802ff31f.tar.bz2
Merged revisions 64549 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r64549 | brett.cannon | 2008-06-26 17:31:13 -0700 (Thu, 26 Jun 2008) | 7 lines warnings.warn_explicit() did not have the proper TypeErrors in place to prevent bus errors or SystemError being raised. As a side effect of fixing this, a bad DECREF that could be triggered when 'message' and 'category' were both None was fixed. Closes issue 3211. Thanks JP Calderone for the bug report. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_warnings.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 6fb3c0e..1e17313 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -301,6 +301,21 @@ class WarnTests(unittest.TestCase):
warning_tests.__name__ = module_name
sys.argv = argv
+ def test_warn_explicit_type_errors(self):
+ # warn_explicit() shoud error out gracefully if it is given objects
+ # of the wrong types.
+ # lineno is expected to be an integer.
+ self.assertRaises(TypeError, self.module.warn_explicit,
+ None, UserWarning, None, None)
+ # Either 'message' needs to be an instance of Warning or 'category'
+ # needs to be a subclass.
+ self.assertRaises(TypeError, self.module.warn_explicit,
+ None, None, None, 1)
+ # 'registry' must be a dict or None.
+ self.assertRaises((TypeError, AttributeError),
+ self.module.warn_explicit,
+ None, Warning, None, 1, registry=42)
+
class CWarnTests(BaseTest, WarnTests):