cpython: b9f7b1bf36aa (original) (raw)
Mercurial > cpython
changeset 82502:b9f7b1bf36aa
Issue #17223: Fix PyUnicode_FromUnicode() on Windows (16-bit wchar_t type) to reject invalid UTF-16 surrogate. [#17223]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Wed, 06 Mar 2013 00:41:50 +0100 |
parents | 15190138d3f3 |
children | 583a0321c7b9 |
files | Misc/NEWS Objects/unicodeobject.c |
diffstat | 2 files changed, 15 insertions(+), 7 deletions(-)[+] [-] Misc/NEWS 3 Objects/unicodeobject.c 19 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #17223: Fix PyUnicode_FromUnicode() on Windows (16-bit wchar_t type)
- Issue #17032: The "global" in the "NameError: global name 'x' is not defined" error message has been removed. Patch by Ram Rachum.
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1384,13 +1384,18 @@ find_maxchar_surrogates(const wchar_t *b for (iter = begin; iter < end; ) { #if SIZEOF_WCHAR_T == 2
if (Py_UNICODE_IS_HIGH_SURROGATE(iter[0])[](#l2.7)
&& (iter+1) < end[](#l2.8)
&& Py_UNICODE_IS_LOW_SURROGATE(iter[1]))[](#l2.9)
{[](#l2.10)
ch = Py_UNICODE_JOIN_SURROGATES(iter[0], iter[1]);[](#l2.11)
++(*num_surrogates);[](#l2.12)
iter += 2;[](#l2.13)
if (Py_UNICODE_IS_HIGH_SURROGATE(iter[0])) {[](#l2.14)
if ((iter+1) < end[](#l2.15)
&& Py_UNICODE_IS_LOW_SURROGATE(iter[1]))[](#l2.16)
{[](#l2.17)
ch = Py_UNICODE_JOIN_SURROGATES(iter[0], iter[1]);[](#l2.18)
++(*num_surrogates);[](#l2.19)
iter += 2;[](#l2.20)
}[](#l2.21)
else {[](#l2.22)
PyErr_SetString(PyExc_ValueError, "illegal UTF-16 surrogate");[](#l2.23)
return -1;[](#l2.24)
}[](#l2.25) }[](#l2.26) else[](#l2.27)