Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
85976b14
Commit
85976b14
authored
Sep 29, 2015
by
Eric V. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #25034: Fix string.Formatter problem with auto-numbering
and nested format_specs. Patch by Anthon van der Neut.
parent
b8b951f6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
5 deletions
+12
-5
Lib/string.py
Lib/string.py
+6
-5
Lib/test/test_string.py
Lib/test/test_string.py
+2
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/string.py
View file @
85976b14
...
...
@@ -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,
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):
...
...
Lib/test/test_string.py
View file @
85976b14
...
...
@@ -54,6 +54,8 @@ class ModuleTest(unittest.TestCase):
'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
))
...
...
Misc/ACKS
View file @
85976b14
...
...
@@ -984,6 +984,7 @@ Tony Nelson
Trent Nelson
Chad Netzer
Max Neunhöffer
Anthon van der Neut
George Neville-Neil
Hieu Nguyen
Johannes Nicolai
...
...
Misc/NEWS
View file @
85976b14
...
...
@@ -78,6 +78,9 @@ Core and Builtins
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
#
23600
:
Default
implementation
of
tzinfo
.
fromutc
()
was
returning
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment