changeset: 98394:65d7b4fd0332 branch: 3.5 parent: 98390:a4bf231d81d3 parent: 98393:9eae18e8af66 user: Eric V. Smith date: Tue Sep 29 10:30:04 2015 -0400 files: Lib/string.py Lib/test/test_string.py Misc/ACKS Misc/NEWS description: Issue #25034: Merge from 3.4. diff -r a4bf231d81d3 -r 65d7b4fd0332 Lib/string.py --- a/Lib/string.py Tue Sep 29 15:50:45 2015 +0300 +++ b/Lib/string.py Tue Sep 29 10:30:04 2015 -0400 @@ -188,7 +188,7 @@ def vformat(self, format_string, args, kwargs): used_args = set() - result = self._vformat(format_string, args, kwargs, used_args, 2) + result, _ = self._vformat(format_string, args, kwargs, used_args, 2) self.check_unused_args(used_args, args, kwargs) return result @@ -235,14 +235,15 @@ obj = self.convert_field(obj, conversion) # expand the format spec, if needed - format_spec = self._vformat(format_spec, args, kwargs, - used_args, recursion_depth-1, - auto_arg_index=auto_arg_index) + format_spec, auto_arg_index = self._vformat( + format_spec, args, kwargs, + used_args, recursion_depth-1, + auto_arg_index=auto_arg_index) # format the object and append to the result result.append(self.format_field(obj, format_spec)) - return ''.join(result) + return ''.join(result), auto_arg_index def get_value(self, key, args, kwargs): diff -r a4bf231d81d3 -r 65d7b4fd0332 Lib/test/test_string.py --- a/Lib/test/test_string.py Tue Sep 29 15:50:45 2015 +0300 +++ b/Lib/test/test_string.py Tue Sep 29 10:30:04 2015 -0400 @@ -58,6 +58,8 @@ 'foo{1}{num}{1}'.format(None, 'bar', num=6)) self.assertEqual(fmt.format('{:^{}}', 'bar', 6), '{:^{}}'.format('bar', 6)) + self.assertEqual(fmt.format('{:^{}} {}', 'bar', 6, 'X'), + '{:^{}} {}'.format('bar', 6, 'X')) self.assertEqual(fmt.format('{:^{pad}}{}', 'foo', 'bar', pad=6), '{:^{pad}}{}'.format('foo', 'bar', pad=6)) diff -r a4bf231d81d3 -r 65d7b4fd0332 Misc/ACKS --- a/Misc/ACKS Tue Sep 29 15:50:45 2015 +0300 +++ b/Misc/ACKS Tue Sep 29 10:30:04 2015 -0400 @@ -1012,6 +1012,7 @@ Trent Nelson Chad Netzer Max Neunhöffer +Anthon van der Neut George Neville-Neil Hieu Nguyen Johannes Nicolai diff -r a4bf231d81d3 -r 65d7b4fd0332 Misc/NEWS --- a/Misc/NEWS Tue Sep 29 15:50:45 2015 +0300 +++ b/Misc/NEWS Tue Sep 29 10:30:04 2015 -0400 @@ -21,6 +21,9 @@ Library ------- +- Issue #25034: Fix string.Formatter problem with auto-numbering and + nested format_specs. Patch by Anthon van der Neut. + - Issue #25233: Rewrite the guts of asyncio.Queue to be more understandable and correct. - Issue #25203: Failed readline.set_completer_delims() no longer left the