Ben Wolfson <wolf...@gmail.com> added the comment: And here is a patch for Greg Ewing's proposal: http://mail.python.org/pipermail/python-dev/2011-June/111934.html
Again, decimal integers rather than any kind of integers are used. Both patches alter the exceptions expected in various places in test_unicode's test_format: "{0.}".format() raises a ValueError (because the format string is invalid) rather than an IndexError (because there is no argument) "{0[}".format(), likewise. "{0]}".format() raises a ValueError (because the format string is invalid) rather than a KeyError (because "0]" is taken to be the name of a keyword argument---meaning that the test suite was testing the actual behavior of the implementation rather than the documented behavior). "{c]}".format(), likewise. In this patch, "{0[{1}]}".format('abcdef', 4) raises a ValueError rather than a TypeError, because "{1}", being neither a decimalinteger nor an identifier, invalidates the replacement field. Both patches also add tests for constructions like this: "{[0]}".format([3]) --> '3' "{.__class__}".format(3) --> "<type 'int'>" This conforms with the documentation (and current behavior), since in it arg_name is defined to be optional, but it is not currently covered in test_format, that I could tell, anyway. ---------- Added file: http://bugs.python.org/file22599/strformat-just-identifiers-please.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12014> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com