From 12be46ca8418593fb2716234912b6a8a8d262966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 4 Nov 2011 19:04:15 +0100 Subject: Drop Py_UNICODE based encode exceptions. --- Objects/unicodeobject.c | 82 +++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 60 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 8b33f44..5d9b517 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -254,12 +254,6 @@ unicode_encode_call_errorhandler(const char *errors, static void raise_encode_exception(PyObject **exceptionObject, const char *encoding, - const Py_UNICODE *unicode, Py_ssize_t size, - Py_ssize_t startpos, Py_ssize_t endpos, - const char *reason); -static void -raise_encode_exception_obj(PyObject **exceptionObject, - const char *encoding, PyObject *unicode, Py_ssize_t startpos, Py_ssize_t endpos, const char *reason); @@ -3058,8 +3052,7 @@ PyUnicode_EncodeFSDefault(PyObject *unicode) if (errmsg == NULL) errmsg = "Py_wchar2char() failed"; raise_encode_exception(&exc, - "filesystemencoding", - PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode), + "filesystemencoding", unicode, error_pos, error_pos+1, errmsg); Py_XDECREF(exc); @@ -4783,7 +4776,7 @@ _PyUnicode_AsUTF8String(PyObject *unicode, const char *errors) for(k=0; k0; ++i, ++str) { c = PyUnicode_READ_CHAR(repunicode, i); if (c >= limit) { - raise_encode_exception_obj(&exc, encoding, unicode, + raise_encode_exception(&exc, encoding, unicode, pos, pos+1, reason); Py_DECREF(repunicode); goto onError; @@ -7434,7 +7388,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, if (errors == NULL || strcmp(errors, "strict") == 0) { /* The last error was ERROR_NO_UNICODE_TRANSLATION, then we raise a UnicodeEncodeError. */ - make_encode_exception_obj(&exc, encoding, unicode, 0, 0, reason); + make_encode_exception(&exc, encoding, unicode, 0, 0, reason); if (exc != NULL) { PyCodec_StrictErrors(exc); Py_DECREF(exc); @@ -7555,7 +7509,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes, for (i=0; i < outsize; i++) { Py_UCS4 ch = PyUnicode_READ(kind, data, i); if (ch > 127) { - raise_encode_exception_obj(&exc, + raise_encode_exception(&exc, encoding, unicode, pos, pos + 1, "unable to encode error handler result to ASCII"); @@ -8250,7 +8204,7 @@ charmap_encoding_error( } switch (*known_errorHandler) { case 1: /* strict */ - raise_encode_exception_obj(exceptionObject, encoding, unicode, collstartpos, collendpos, reason); + raise_encode_exception(exceptionObject, encoding, unicode, collstartpos, collendpos, reason); return -1; case 2: /* replace */ for (collpos = collstartpos; collpos