]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 72850 via svnmerge from
authorEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:38:19 +0000 (14:38 +0000)
committerEric Smith <eric@trueblade.com>
Sat, 23 May 2009 14:38:19 +0000 (14:38 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r72850 | eric.smith | 2009-05-23 10:23:22 -0400 (Sat, 23 May 2009) | 9 lines

  Merged revisions 72848 via svnmerge from
  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 aaed2d4113515b87abd84c5550e0e12f0f1e624a..c51949f50c19c2d781d85e063ef12cd066317747 100644 (file)
@@ -688,6 +688,10 @@ class UnicodeTest(
         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 2b40d6835b1ca3fceff97e0604c07034aea4b442..3b8aa9f8e45115c5ab8e6002ec55b042b7472061 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.0.2?
 Core and Builtins
 -----------------
 
+- Issue #6089: Fixed str.format with certain invalid field specifiers
+  that would raise SystemError.
+
 - Issue #5994: the marshal module now has docstrings.
 
 - Issue #5981: Fix two minor inf/nan issues in float.fromhex: (1) inf
index b8287701fa15a5d40216f9383d91ee2f6cb24c31..58af393302fcb24367ef252f674e805bb99bd624 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;
     }