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
c12469df
Commit
c12469df
authored
Jul 18, 2011
by
Eric V. Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 3.2.
parents
677b6530
12ebefc9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
0 deletions
+20
-0
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+5
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+4
-0
Objects/stringlib/string_format.h
Objects/stringlib/string_format.h
+10
-0
No files found.
Lib/test/test_unicode.py
View file @
c12469df
...
...
@@ -736,6 +736,11 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertRaises
(
TypeError
,
'{a'
.
format_map
)
self
.
assertRaises
(
TypeError
,
'}a'
.
format_map
)
# issue #12579: can't supply positional params to format_map
self
.
assertRaises
(
ValueError
,
'{}'
.
format_map
,
{
'a'
:
2
})
self
.
assertRaises
(
ValueError
,
'{}'
.
format_map
,
'a'
)
self
.
assertRaises
(
ValueError
,
'{a} {}'
.
format_map
,
{
"a"
:
2
,
"b"
:
1
})
def
test_format_auto_numbering
(
self
):
class
C
:
def
__init__
(
self
,
x
=
100
):
...
...
Misc/ACKS
View file @
c12469df
...
...
@@ -82,6 +82,7 @@ Eli Bendersky
Andrew Bennetts
Andy Bensky
Michel Van den Bergh
Julian Berman
Eric Beser
Steven Bethard
Stephen Bevan
...
...
Misc/NEWS
View file @
c12469df
...
...
@@ -10,6 +10,10 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
- Issue #12579: str.format_map() now raises a ValueError if used on a
format string that contains positional fields. Initial patch by
Julian Berman.
- Issue #10271: Allow warnings.showwarning() be any callable.
- Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
...
...
Objects/stringlib/string_format.h
View file @
c12469df
...
...
@@ -511,6 +511,16 @@ get_field_object(SubString *input, PyObject *args, PyObject *kwargs,
Py_DECREF
(
key
);
}
else
{
/* If args is NULL, we have a format string with a positional field
with only kwargs to retrieve it from. This can only happen when
used with format_map(), where positional arguments are not
allowed. */
if
(
args
==
NULL
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Format string contains "
"positional fields"
);
goto
error
;
}
/* look up in args */
obj
=
PySequence_GetItem
(
args
,
index
);
if
(
obj
==
NULL
)
...
...
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