]> granicus.if.org Git - python/commitdiff
Merged revisions 72848 via svnmerge from
authorEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:04:31 +0000 (14:04 +0000)
committerEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:04:31 +0000 (14:04 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72848 | eric.smith | 2009-05-23 09:56:13 -0400 (Sat, 23 May 2009) | 1 line

  Issue 6089: str.format raises SystemError.
........

Lib/test/test_str.py
Lib/test/test_unicode.py
Misc/NEWS
Objects/stringlib/string_format.h

index 044711cad512ef57507735fef12c11977c52ff69..de988a88721db1b8d9dbb7f7a0cb412c620318e1 100644 (file)
@@ -351,6 +351,10 @@ class StrTest(
         self.assertRaises(ValueError, "{:s}".format)
         self.assertRaises(ValueError, "{}".format)
 
+        # issue 6089
+        self.assertRaises(ValueError, "{0[0]x}".format, [None])
+        self.assertRaises(ValueError, "{0[0](10)}".format, [None])
+
         # can't have a replacement on the field name portion
         self.assertRaises(TypeError, '{0[{1}]}'.format, 'abcdefg', 4)
 
index 968f64b1616bdd49bdd8f626fa85bcf586677b81..96c15f03a3c7d8910f2836c952d3b3dfed95d7b5 100644 (file)
@@ -1091,6 +1091,10 @@ class UnicodeTest(
         self.assertRaises(ValueError, u"{:s}".format)
         self.assertRaises(ValueError, u"{}".format)
 
+        # issue 6089
+        self.assertRaises(ValueError, u"{0[0]x}".format, [None])
+        self.assertRaises(ValueError, u"{0[0](10)}".format, [None])
+
         # can't have a replacement on the field name portion
         self.assertRaises(TypeError, u'{0[{1}]}'.format, u'abcdefg', 4)
 
index 61717a05e2d967150b609486151eef56668199db..2b1630fd2bbcdbfb82193ce572f819f7a18e5c74 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6.3
 Core and Builtins
 -----------------
 
+- Issue #6089: str.format can raise SystemError with certain invalid
+  field specifiers.
+
 - Issue #5994: the marshal module now has docstrings.
 
 - Issue #5981: Fix two minor inf/nan issues in float.fromhex: (1) inf
index 600e6b04a1145f7e55b7e84f0a8d537c44c2647e..6c531e89c75845e7fb509afb45368ad020aaa7eb 100644 (file)
@@ -329,8 +329,9 @@ FieldNameIterator_next(FieldNameIterator *self, int *is_attribute,
         *name_idx = get_integer(name);
         break;
     default:
-        /* interal error, can't get here */
-        assert(0);
+        /* Invalid character follows ']' */
+        PyErr_SetString(PyExc_ValueError, "Only '.' or '[' may "
+                        "follow ']' in format field specifier");
         return 0;
     }