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
a708adfc
Commit
a708adfc
authored
Jan 02, 2013
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call PyErr_Clear() when ignoring error from PyNumber_Int (closes #15516)
Patch from Tom Tromey.
parent
140794d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
Lib/test/test_format.py
Lib/test/test_format.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/stringobject.c
Objects/stringobject.c
+4
-1
No files found.
Lib/test/test_format.py
View file @
a708adfc
...
...
@@ -234,6 +234,16 @@ class FormatTest(unittest.TestCase):
testformat
(
'%g'
,
1.1
,
'1.1'
)
testformat
(
'%#g'
,
1.1
,
'1.10000'
)
# Regression test for http://bugs.python.org/issue15516.
class
IntFails
(
object
):
def
__int__
(
self
):
raise
TestFailed
def
__long__
(
self
):
return
0
fst
=
IntFails
()
testformat
(
"%x"
,
fst
,
'0'
)
# Test exception for unknown format characters
if
verbose
:
print
'Testing exceptions'
...
...
Misc/NEWS
View file @
a708adfc
...
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins
-----------------
- Issue #15516: Fix a bug in PyString_FromFormat where it failed to properly
ignore errors from a __int__() method.
- Issue #16839: Fix a segfault when calling unicode() on a classic class early
in interpreter initialization.
...
...
Objects/stringobject.c
View file @
a708adfc
...
...
@@ -4489,7 +4489,10 @@ PyString_Format(PyObject *format, PyObject *args)
}
else
{
iobj
=
PyNumber_Int
(
v
);
if
(
iobj
==
NULL
)
iobj
=
PyNumber_Long
(
v
);
if
(
iobj
==
NULL
)
{
PyErr_Clear
();
iobj
=
PyNumber_Long
(
v
);
}
}
if
(
iobj
!=
NULL
)
{
if
(
PyInt_Check
(
iobj
))
{
...
...
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