cpython: 2f1e8b7fa534 (original) (raw)
Mercurial > cpython
changeset 84283:2f1e8b7fa534 2.7
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise OverflowError when an argument of %c format is out of range. [#18184]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Sun, 23 Jun 2013 20:22:09 +0300 |
parents | 8f0adcb66633 |
children | 86d512e0ec66 |
files | Misc/NEWS Objects/unicodeobject.c |
diffstat | 2 files changed, 21 insertions(+), 1 deletions(-)[+] [-] Misc/NEWS 3 Objects/unicodeobject.c 19 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ What's New in Python 2.7.6? Core and Builtins ----------------- +- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -740,8 +740,25 @@ PyUnicode_FromFormatV(const char *format switch (*f) { case 'c':
(void)va_arg(count, int);[](#l2.7)
{[](#l2.8)
int ordinal = va_arg(count, int);[](#l2.9)
if (ordinal < 0 || ordinal > 0x10ffff) {[](#l2.11)
PyErr_SetString(PyExc_OverflowError,[](#l2.12)
"%c arg not in range(0x110000) "[](#l2.13)
"(wide Python build)");[](#l2.14)
goto fail;[](#l2.15)
}[](#l2.16)
if (ordinal < 0 || ordinal > 0xffff) {[](#l2.18)
PyErr_SetString(PyExc_OverflowError,[](#l2.19)
"%c arg not in range(0x10000) "[](#l2.20)
"(narrow Python build)");[](#l2.21)
goto fail;[](#l2.22)
}[](#l2.23)
}[](#l2.26) case '%':[](#l2.27) n++;[](#l2.28) break;[](#l2.29)