Commit 4b94b192 authored by Eric Smith's avatar Eric Smith

Issue 6089: str.format raises SystemError.

parent 8254d398
......@@ -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)
......
......@@ -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)
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment