diff options
author | Eric Smith <eric@trueblade.com> | 2009-05-23 13:56:13 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-05-23 13:56:13 (GMT) |
commit | 4b94b192ff38f37b99f04605fd6515d7fb97ffea (patch) | |
tree | 49f84be105d3b542933b9ea32347c70ae07c5a92 | |
parent | 8254d3984015b8965a33e3ddb8c6fc104090eafd (diff) | |
download | cpython-4b94b192ff38f37b99f04605fd6515d7fb97ffea.zip cpython-4b94b192ff38f37b99f04605fd6515d7fb97ffea.tar.gz cpython-4b94b192ff38f37b99f04605fd6515d7fb97ffea.tar.bz2 |
Issue 6089: str.format raises SystemError.
-rw-r--r-- | Lib/test/test_str.py | 4 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 4 | ||||
-rw-r--r-- | Objects/stringlib/string_format.h | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index 51d2680..5341af2 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -351,6 +351,10 @@ class StrTest( 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) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 83bc584..99155ec 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1100,6 +1100,10 @@ class UnicodeTest( self.assertRaises(IndexError, u"{:s}".format) self.assertRaises(IndexError, 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) diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h index ce7c909..ee6533e 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; } |