[Python-checkins] r74046 - in python/branches/py3k: Lib/test/test_warnings.py Misc/NEWS Python/_warnings.c

hirokazu.yamamoto python-checkins at python.org
Fri Jul 17 08:55:42 CEST 2009


Author: hirokazu.yamamoto
Date: Fri Jul 17 08:55:42 2009
New Revision: 74046
Log:
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.
........
Modified:
 python/branches/py3k/ (props changed)
 python/branches/py3k/Lib/test/test_warnings.py
 python/branches/py3k/Misc/NEWS
 python/branches/py3k/Python/_warnings.c
Modified: python/branches/py3k/Lib/test/test_warnings.py
==============================================================================
--- python/branches/py3k/Lib/test/test_warnings.py	(original)
+++ python/branches/py3k/Lib/test/test_warnings.py	Fri Jul 17 08:55:42 2009
@@ -338,6 +338,20 @@
 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
 
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Jul 17 08:55:42 2009
@@ -40,6 +40,8 @@
 Library
 -------
 
+- Issue #6415: Fixed warnings.warn sagfault on bad formatted string.
+
 - Issue #6358: The exit status of a command started with os.popen() was
 reported differently than it did with python 2.x.
 
Modified: python/branches/py3k/Python/_warnings.c
==============================================================================
--- python/branches/py3k/Python/_warnings.c	(original)
+++ python/branches/py3k/Python/_warnings.c	Fri Jul 17 08:55:42 2009
@@ -320,6 +320,8 @@
 }
 if (rc == 1) {
 text = PyObject_Str(message);
+ if (text == NULL)
+ goto cleanup;
 category = (PyObject*)message->ob_type;
 }
 else {


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /