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
d2b58a98
Commit
d2b58a98
authored
May 17, 2013
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only recursively expand in the format spec (closes #17644)
parent
36f74aa7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+2
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/stringlib/unicode_format.h
Objects/stringlib/unicode_format.h
+8
-2
No files found.
Lib/test/test_unicode.py
View file @
d2b58a98
...
...
@@ -934,6 +934,8 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
"{0:.0s}"
.
format
(
"ABC
\
u0410
\
u0411
\
u0412
"
),
''
)
self
.
assertEqual
(
"{[{}]}"
.
format
({
"{}"
:
5
}),
"5"
)
def
test_format_map
(
self
):
self
.
assertEqual
(
''
.
format_map
({}),
''
)
self
.
assertEqual
(
'a'
.
format_map
({}),
'a'
)
...
...
Misc/NEWS
View file @
d2b58a98
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.3 release candidate 1?
Core and Builtins
-----------------
- Issue #17644: Fix a crash in str.format when curly braces are used in square
brackets.
- Issue #17983: Raise a SyntaxError for a ``global __class__`` statement in a
class body.
...
...
Objects/stringlib/unicode_format.h
View file @
d2b58a98
...
...
@@ -638,7 +638,7 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal,
SubString
*
format_spec
,
Py_UCS4
*
conversion
,
int
*
format_spec_needs_expanding
)
{
int
at_end
;
int
at_end
,
hit_format_spec
;
Py_UCS4
c
=
0
;
Py_ssize_t
start
;
int
count
;
...
...
@@ -723,11 +723,17 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal,
/* we know we can't have a zero length string, so don't worry
about that case */
hit_format_spec
=
0
;
while
(
self
->
str
.
start
<
self
->
str
.
end
)
{
switch
(
c
=
PyUnicode_READ_CHAR
(
self
->
str
.
str
,
self
->
str
.
start
++
))
{
case
':'
:
hit_format_spec
=
1
;
count
=
1
;
break
;
case
'{'
:
/* the format spec needs to be recursively expanded.
this is an optimization, and not strictly needed */
if
(
hit_format_spec
)
*
format_spec_needs_expanding
=
1
;
count
++
;
break
;
...
...
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