]> granicus.if.org Git - python/commitdiff
Merged revisions 72848 via svnmerge from
authorEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:23:22 +0000 (14:23 +0000)
committerEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:23:22 +0000 (14:23 +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_unicode.py
Misc/NEWS
Objects/stringlib/string_format.h

index 5aea3673c48ec2349c2e4ee2779cb75c27002098..70eb871798f7f82e6c6b5e24baf6ccbee64cb83a 100644 (file)
@@ -688,6 +688,10 @@ class UnicodeTest(
         self.assertRaises(IndexError, "{:s}".format)
         self.assertRaises(IndexError, "{}".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 611dbeae335dedf3e18e225c788eeb42823fc1b6..9d190ff8890ee3cdeb72a24338185c68b516e841 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.1 release candidate 1?
 Core and Builtins
 -----------------
 
+- Issue #6089: Fixed str.format with certain invalid field specifiers
+  that would raise SystemError.
+
 - Issue #5829: complex("1e500") no longer raises OverflowError.  This
   makes it consistent with float("1e500") and interpretation of real
   and imaginary literals.
index 0f57f3fdd463d1e7605709d8078b14726a0b4373..539feaee189078c96101c87d0e24b10012a95238 100644 (file)
@@ -375,8 +375,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;
     }