From 85976b14ddb941670ee831ed18b5bc69ca1380ac Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Tue, 29 Sep 2015 10:27:38 -0400 Subject: Fixed issue #25034: Fix string.Formatter problem with auto-numbering and nested format_specs. Patch by Anthon van der Neut. --- Lib/string.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Lib/string.py') diff --git a/Lib/string.py b/Lib/string.py index a4c48b2837..ef0787f52b 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -185,7 +185,7 @@ class Formatter: 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 @@ -232,14 +232,15 @@ class Formatter: 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): -- cgit v1.2.1