Commit 149d0808 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #13410: Fixed a bug in PyUnicode_Format where it failed to properly

ignore errors from a __int__() method.

Patch based on the patch for issue #15516.
parent f1669a39
......@@ -243,6 +243,7 @@ class FormatTest(unittest.TestCase):
fst = IntFails()
testformat("%x", fst, '0')
testformat(u"%x", fst, '0')
# Test exception for unknown format characters
if verbose:
......
......@@ -10,6 +10,9 @@ What's New in Python 2.7.12?
Core and Builtins
-----------------
- Issue #13410: Fixed a bug in PyUnicode_Format where it failed to properly
ignore errors from a __int__() method.
- Issue #26494: Fixed crash on iterating exhausting iterators.
Affected classes are generic sequence iterators, iterators of bytearray,
list, tuple, set, frozenset, dict, OrderedDict and corresponding views.
......
......@@ -8632,7 +8632,10 @@ PyObject *PyUnicode_Format(PyObject *format,
}
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)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment