[Python-checkins] cpython (merge 3.3 -> default): Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
serhiy.storchaka
python-checkins at python.org
Sun Jun 23 19:55:58 CEST 2013
http://hg.python.org/cpython/rev/42def600210e
changeset: 84282:42def600210e
parent: 84277:6fd45b004d78
parent: 84281:f8ede55cf92b
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Jun 23 20:21:16 2013 +0300
summary:
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
OverflowError when an argument of %c format is out of range.
files:
Lib/test/test_unicode.py | 2 ++
Misc/NEWS | 3 +++
Objects/unicodeobject.c | 2 +-
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -2048,6 +2048,8 @@
b'%c', c_int(0xabcd))
check_format('\U0010ffff',
b'%c', c_int(0x10ffff))
+ with self.assertRaises(OverflowError):
+ PyUnicode_FromFormat(b'%c', c_int(0x110000))
# Issue #18183
check_format('\U00010000\U00100000',
b'%c%c', c_int(0x10000), c_int(0x100000))
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
+ OverflowError when an argument of %c format is out of range.
+
- Issue #18137: Detect integer overflow on precision in float.__format__()
and complex.__format__().
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2496,7 +2496,7 @@
{
int ordinal = va_arg(*vargs, int);
if (ordinal < 0 || ordinal > MAX_UNICODE) {
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_OverflowError,
"character argument not in range(0x110000)");
return NULL;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list