From cf77da9fb5a0b23c92c5005b13944f680aa0f325 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 6 Mar 2013 01:09:24 +0100 Subject: Backed out changeset b9f7b1bf36aa --- Misc/NEWS | 3 --- Objects/unicodeobject.c | 19 +++++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index d858cd2..a0dd2f6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,9 +10,6 @@ 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) - to reject invalid UTF-16 surrogate. - - Issue #17032: The "global" in the "NameError: global name 'x' is not defined" error message has been removed. Patch by Ram Rachum. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 00a6a36..2175655 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1384,18 +1384,13 @@ find_maxchar_surrogates(const wchar_t *begin, const wchar_t *end, for (iter = begin; iter < end; ) { #if SIZEOF_WCHAR_T == 2 - if (Py_UNICODE_IS_HIGH_SURROGATE(iter[0])) { - if ((iter+1) < end - && Py_UNICODE_IS_LOW_SURROGATE(iter[1])) - { - ch = Py_UNICODE_JOIN_SURROGATES(iter[0], iter[1]); - ++(*num_surrogates); - iter += 2; - } - else { - PyErr_SetString(PyExc_ValueError, "illegal UTF-16 surrogate"); - return -1; - } + if (Py_UNICODE_IS_HIGH_SURROGATE(iter[0]) + && (iter+1) < end + && Py_UNICODE_IS_LOW_SURROGATE(iter[1])) + { + ch = Py_UNICODE_JOIN_SURROGATES(iter[0], iter[1]); + ++(*num_surrogates); + iter += 2; } else #endif -- cgit v0.12