diff -r 7bff23ec3f5b Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py Sun Jul 17 10:13:44 2011 -0400 +++ b/Lib/test/test_unicode.py Sun Jul 17 20:59:03 2011 -0400 @@ -1,4 +1,4 @@ -""" Test script for the Unicode implementation. +""" Test script forathe Unicode implementation. Written by Marc-Andre Lemburg (mal@lemburg.com). @@ -736,6 +736,11 @@ self.assertRaises(TypeError, '{a'.format_map) self.assertRaises(TypeError, '}a'.format_map) + # test positional error + self.assertRaises(ValueError, '{}'.format_map, {'a' : 2}) + self.assertRaises(ValueError, '{}'.format_map, 'a') + self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1}) + def test_format_auto_numbering(self): class C: def __init__(self, x=100): diff -r 7bff23ec3f5b Misc/ACKS --- a/Misc/ACKS Sun Jul 17 10:13:44 2011 -0400 +++ b/Misc/ACKS Sun Jul 17 20:59:03 2011 -0400 @@ -82,6 +82,7 @@ Andrew Bennetts Andy Bensky Michel Van den Bergh +Julian Berman Eric Beser Steven Bethard Stephen Bevan diff -r 7bff23ec3f5b Objects/stringlib/string_format.h --- a/Objects/stringlib/string_format.h Sun Jul 17 10:13:44 2011 -0400 +++ b/Objects/stringlib/string_format.h Sun Jul 17 20:59:03 2011 -0400 @@ -511,6 +511,14 @@ Py_DECREF(key); } else { + /* If args is NULL, we have a format string with a positional field + with only kwargs to retrieve it from. */ + if (args == NULL) { + PyErr_SetString(PyExc_ValueError, "Format string contained " + "positional fields"); + goto error; + } + /* look up in args */ obj = PySequence_GetItem(args, index); if (obj == NULL)