diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-02 19:33:54 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-02 19:33:54 (GMT) |
commit | c53be96c54ec619266ff64b732100bbe0d592b69 (patch) | |
tree | b874cd16c931d327e138f687e91bba9bd611eb7e /Objects | |
parent | c3c7415639bff8f1a3da18b9a170bb172f834c5b (diff) | |
download | cpython-c53be96c54ec619266ff64b732100bbe0d592b69.zip cpython-c53be96c54ec619266ff64b732100bbe0d592b69.tar.gz cpython-c53be96c54ec619266ff64b732100bbe0d592b69.tar.bz2 |
unicode_convert_wchar_to_ucs4() cannot fail
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2c48c82..1aabd2e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -590,7 +590,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar) This function assumes that unicode can hold one more code point than wstr characters for a terminating null character. */ -static int +static void unicode_convert_wchar_to_ucs4(const wchar_t *begin, const wchar_t *end, PyUnicodeObject *unicode) { @@ -757,6 +757,7 @@ find_maxchar_surrogates(const wchar_t *begin, const wchar_t *end, { const wchar_t *iter; + assert(num_surrogates != NULL && maxchar != NULL); if (num_surrogates == NULL || maxchar == NULL) { PyErr_SetString(PyExc_SystemError, "unexpected NULL arguments to " @@ -903,11 +904,7 @@ _PyUnicode_Ready(PyObject *obj) _PyUnicode_STATE(unicode).kind = PyUnicode_4BYTE_KIND; _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; - if (unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, - unicode) < 0) { - assert(0 && "ConvertWideCharToUCS4 failed"); - return -1; - } + unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, unicode); PyObject_FREE(_PyUnicode_WSTR(unicode)); _PyUnicode_WSTR(unicode) = NULL; _PyUnicode_WSTR_LENGTH(unicode) = 0; @@ -1081,10 +1078,7 @@ PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size) #if SIZEOF_WCHAR_T == 2 /* This is the only case which has to process surrogates, thus a simple copy loop is not enough and we need a function. */ - if (unicode_convert_wchar_to_ucs4(u, u + size, unicode) < 0) { - Py_DECREF(unicode); - return NULL; - } + unicode_convert_wchar_to_ucs4(u, u + size, unicode); #else assert(num_surrogates == 0); Py_MEMCPY(PyUnicode_4BYTE_DATA(unicode), u, size * 4); |