[Python-checkins] cpython (2.7): Issue #13410: Fixed a bug in PyUnicode_Format where it failed to properly
serhiy.storchaka
python-checkins at python.org
Sun Apr 10 08:27:34 EDT 2016
https://hg.python.org/cpython/rev/a06654ca0134
changeset: 100906:a06654ca0134
branch: 2.7
parent: 100900:4dc347c5c8a8
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Apr 10 15:26:52 2016 +0300
summary:
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.
files:
Lib/test/test_format.py | 1 +
Misc/NEWS | 3 +++
Objects/unicodeobject.c | 5 ++++-
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -243,6 +243,7 @@
fst = IntFails()
testformat("%x", fst, '0')
+ testformat(u"%x", fst, '0')
# Test exception for unknown format characters
if verbose:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
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.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8632,7 +8632,10 @@
}
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)) {
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list