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
23d49d3e
Commit
23d49d3e
authored
Aug 28, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the stricter PyMapping_Check (closes #15801)
parent
25cf30fa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
2 deletions
+8
-2
Lib/test/string_tests.py
Lib/test/string_tests.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/stringobject.c
Objects/stringobject.c
+1
-1
Objects/unicodeobject.c
Objects/unicodeobject.c
+1
-1
No files found.
Lib/test/string_tests.py
View file @
23d49d3e
...
...
@@ -1113,6 +1113,9 @@ class MixinStrUnicodeUserStringTest:
self
.
checkraises
(
TypeError
,
'%10.*f'
,
'__mod__'
,
(
'foo'
,
42.
))
self
.
checkraises
(
ValueError
,
'%10'
,
'__mod__'
,
(
42
,))
class
X
(
object
):
pass
self
.
checkraises
(
TypeError
,
'abc'
,
'__mod__'
,
X
())
def
test_floatformatting
(
self
):
# float formatting
for
prec
in
xrange
(
100
):
...
...
Misc/NEWS
View file @
23d49d3e
...
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins
-----------------
- Issue #15801: Make sure mappings passed to '
%
' formatting are actually
subscriptable.
- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
errors correctly. Patch by Serhiy Storchaka.
...
...
Objects/stringobject.c
View file @
23d49d3e
...
...
@@ -4254,7 +4254,7 @@ PyString_Format(PyObject *format, PyObject *args)
arglen
=
-
1
;
argidx
=
-
2
;
}
if
(
Py
_TYPE
(
args
)
->
tp_as_mapping
&&
!
PyTuple_Check
(
args
)
&&
if
(
Py
Mapping_Check
(
args
)
&&
!
PyTuple_Check
(
args
)
&&
!
PyObject_TypeCheck
(
args
,
&
PyBaseString_Type
))
dict
=
args
;
while
(
--
fmtcnt
>=
0
)
{
...
...
Objects/unicodeobject.c
View file @
23d49d3e
...
...
@@ -8275,7 +8275,7 @@ PyObject *PyUnicode_Format(PyObject *format,
arglen
=
-
1
;
argidx
=
-
2
;
}
if
(
Py
_TYPE
(
args
)
->
tp_as_mapping
&&
!
PyTuple_Check
(
args
)
&&
if
(
Py
Mapping_Check
(
args
)
&&
!
PyTuple_Check
(
args
)
&&
!
PyObject_TypeCheck
(
args
,
&
PyBaseString_Type
))
dict
=
args
;
...
...
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