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:20:46 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-07-17 06:20:46 (GMT)
commite78e5d2e515167df8fdf0a551e8333c31c6a1ba3 (patch)
treec2e1a0cd2d72eb5a4679e58404853dd0d1b85574 /Lib/test/test_warnings.py
parent66da2635ff0f3eed66d0c6d6e2e3e67d5943950c (diff)
downloadcpython-e78e5d2e515167df8fdf0a551e8333c31c6a1ba3.zip
cpython-e78e5d2e515167df8fdf0a551e8333c31c6a1ba3.tar.gz
cpython-e78e5d2e515167df8fdf0a551e8333c31c6a1ba3.tar.bz2
Issue #6415: Fixed warnings.warn sagfault on bad formatted string.
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index ca27519..d093994 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -327,6 +327,19 @@ 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