mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #25034: Merge from 3.4.
This commit is contained in:
commit
ad4003c7fb
4 changed files with 12 additions and 5 deletions
|
@ -188,7 +188,7 @@ class Formatter:
|
||||||
|
|
||||||
def vformat(self, format_string, args, kwargs):
|
def vformat(self, format_string, args, kwargs):
|
||||||
used_args = set()
|
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)
|
self.check_unused_args(used_args, args, kwargs)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -235,14 +235,15 @@ class Formatter:
|
||||||
obj = self.convert_field(obj, conversion)
|
obj = self.convert_field(obj, conversion)
|
||||||
|
|
||||||
# expand the format spec, if needed
|
# expand the format spec, if needed
|
||||||
format_spec = self._vformat(format_spec, args, kwargs,
|
format_spec, auto_arg_index = self._vformat(
|
||||||
used_args, recursion_depth-1,
|
format_spec, args, kwargs,
|
||||||
auto_arg_index=auto_arg_index)
|
used_args, recursion_depth-1,
|
||||||
|
auto_arg_index=auto_arg_index)
|
||||||
|
|
||||||
# format the object and append to the result
|
# format the object and append to the result
|
||||||
result.append(self.format_field(obj, format_spec))
|
result.append(self.format_field(obj, format_spec))
|
||||||
|
|
||||||
return ''.join(result)
|
return ''.join(result), auto_arg_index
|
||||||
|
|
||||||
|
|
||||||
def get_value(self, key, args, kwargs):
|
def get_value(self, key, args, kwargs):
|
||||||
|
|
|
@ -58,6 +58,8 @@ class ModuleTest(unittest.TestCase):
|
||||||
'foo{1}{num}{1}'.format(None, 'bar', num=6))
|
'foo{1}{num}{1}'.format(None, 'bar', num=6))
|
||||||
self.assertEqual(fmt.format('{:^{}}', 'bar', 6),
|
self.assertEqual(fmt.format('{:^{}}', 'bar', 6),
|
||||||
'{:^{}}'.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),
|
self.assertEqual(fmt.format('{:^{pad}}{}', 'foo', 'bar', pad=6),
|
||||||
'{:^{pad}}{}'.format('foo', 'bar', pad=6))
|
'{:^{pad}}{}'.format('foo', 'bar', pad=6))
|
||||||
|
|
||||||
|
|
|
@ -1012,6 +1012,7 @@ Tony Nelson
|
||||||
Trent Nelson
|
Trent Nelson
|
||||||
Chad Netzer
|
Chad Netzer
|
||||||
Max Neunhöffer
|
Max Neunhöffer
|
||||||
|
Anthon van der Neut
|
||||||
George Neville-Neil
|
George Neville-Neil
|
||||||
Hieu Nguyen
|
Hieu Nguyen
|
||||||
Johannes Nicolai
|
Johannes Nicolai
|
||||||
|
|
|
@ -21,6 +21,9 @@ Core and Builtins
|
||||||
Library
|
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 #25233: Rewrite the guts of asyncio.Queue to be more understandable and correct.
|
||||||
|
|
||||||
- Issue #25203: Failed readline.set_completer_delims() no longer left the
|
- Issue #25203: Failed readline.set_completer_delims() no longer left the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue