diff options
-rw-r--r-- | Lib/test/test_unicode.py | 4 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/stringlib/string_format.h | 5 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 5aea367..70eb871 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -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) @@ -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. diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h index 0f57f3f..539feae 100644 --- a/Objects/stringlib/string_format.h +++ b/Objects/stringlib/string_format.h @@ -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; } |