Fix segfault discovered by Ron Adam. Not checking for terminating right bracket in "'{0[}'.format(())". Fixed, and tests added.

This commit is contained in:
Eric Smith 2007-09-03 08:40:29 +00:00
parent f82d9b52fa
commit 4cb4e4e882
2 changed files with 12 additions and 4 deletions

View file

@ -458,6 +458,7 @@ class UnicodeTest(
# weird field names
self.assertEqual("{0[foo-bar]}".format({'foo-bar':'baz'}), 'baz')
self.assertEqual("{0[foo bar]}".format({'foo bar':'baz'}), 'baz')
self.assertEqual("{0[ ]}".format({' ':3}), '3')
self.assertEqual('{foo._x}'.format(foo=C(20)), '20')
self.assertEqual('{1}{0}'.format(D(10), D(20)), '2010')
@ -551,6 +552,7 @@ class UnicodeTest(
self.assertRaises(ValueError, "{0".format)
self.assertRaises(ValueError, "{0.}".format)
self.assertRaises(ValueError, "{0[}".format)
self.assertRaises(ValueError, "{0[}".format, [])
self.assertRaises(ValueError, "{0]}".format)
self.assertRaises(ValueError, "{0.[]}".format)
self.assertRaises(ValueError, "{0..foo}".format, 0)