summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_warnings.py
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-07-17 06:55:42 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-07-17 06:55:42 (GMT)
commit1c0c00371f0aba56515174701587ec53bc6051df (patch)
treee0273f5b3e030732da30f8736f7581b06432a689 /Lib/test/test_warnings.py
parente5091f6c5a8c5120588543661fb9abb3ec46eb43 (diff)
downloadcpython-1c0c00371f0aba56515174701587ec53bc6051df.zip
cpython-1c0c00371f0aba56515174701587ec53bc6051df.tar.gz
cpython-1c0c00371f0aba56515174701587ec53bc6051df.tar.bz2
Merged revisions 74040,74042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74040 | hirokazu.yamamoto | 2009-07-17 15:20:46 +0900 | 1 line Issue #6415: Fixed warnings.warn sagfault on bad formatted string. ........ r74042 | hirokazu.yamamoto | 2009-07-17 15:26:54 +0900 | 1 line NEWS about r74040. ........
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 0910055..7393d25 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -338,6 +338,20 @@ class WarnTests(unittest.TestCase):
self.module.warn_explicit,
None, Warning, None, 1, registry=42)
+ def test_bad_str(self):
+ # issue 6415
+ # Warnings instance with a bad format string for __str__ should not
+ # trigger a bus error.
+ class BadStrWarning(Warning):
+ """Warning with a bad format string for __str__."""
+ def __str__(self):
+ return ("A bad formatted string %(err)" %
+ {"err" : "there is no %(err)s"})
+
+ with self.assertRaises(ValueError):
+ self.module.warn(BadStrWarning())
+
+
class CWarnTests(BaseTest, WarnTests):
module = c_warnings