diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c index 3441f619585..8b225c36a30 100644 --- a/Modules/_codecsmodule.c +++ b/Modules/_codecsmodule.c @@ -14,10 +14,10 @@ The builtin Unicode codecs use the following interface: - _encode(Unicode_object[,errors='strict']) -> + _encode(Unicode_object[,errors='strict']) -> (string object, bytes consumed) - _decode(char_buffer_obj[,errors='strict']) -> + _decode(char_buffer_obj[,errors='strict']) -> (Unicode object, bytes consumed) _encode() interfaces also accept non-Unicode object as @@ -56,7 +56,7 @@ PyObject *codec_register(PyObject *self, PyObject *args) if (PyCodec_Register(search_function)) goto onError; - + Py_INCREF(Py_None); return Py_None; @@ -100,7 +100,7 @@ codec_encode(PyObject *self, PyObject *args) const char *encoding = NULL; const char *errors = NULL; PyObject *v; - + if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors)) return NULL; @@ -140,7 +140,7 @@ codec_decode(PyObject *self, PyObject *args) const char *encoding = NULL; const char *errors = NULL; PyObject *v; - + if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors)) return NULL; @@ -171,7 +171,7 @@ PyObject *codec_tuple(PyObject *unicode, int len) { PyObject *v,*w; - + if (unicode == NULL) return NULL; v = PyTuple_New(2); @@ -197,11 +197,11 @@ escape_decode(PyObject *self, const char *errors = NULL; const char *data; int size; - + if (!PyArg_ParseTuple(args, "s#|z:escape_decode", &data, &size, &errors)) return NULL; - return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL), + return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL), size); } @@ -242,7 +242,7 @@ unicode_internal_decode(PyObject *self, const char *errors = NULL; const char *data; int size; - + if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode", &obj, &errors)) return NULL; @@ -267,7 +267,7 @@ utf_7_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode", &data, &size, &errors)) return NULL; @@ -333,7 +333,7 @@ utf_16_le_decode(PyObject *self, int final = 0; int consumed; PyObject *decoded = NULL; - + if (!PyArg_ParseTuple(args, "t#|zi:utf_16_le_decode", &data, &size, &errors, &final)) return NULL; @@ -357,7 +357,7 @@ utf_16_be_decode(PyObject *self, int final = 0; int consumed; PyObject *decoded = NULL; - + if (!PyArg_ParseTuple(args, "t#|zi:utf_16_be_decode", &data, &size, &errors, &final)) return NULL; @@ -410,7 +410,7 @@ unicode_escape_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode", &data, &size, &errors)) return NULL; @@ -426,7 +426,7 @@ raw_unicode_escape_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode", &data, &size, &errors)) return NULL; @@ -442,7 +442,7 @@ latin_1_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode", &data, &size, &errors)) return NULL; @@ -458,7 +458,7 @@ ascii_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:ascii_decode", &data, &size, &errors)) return NULL; @@ -475,7 +475,7 @@ charmap_decode(PyObject *self, int size; const char *errors = NULL; PyObject *mapping = NULL; - + if (!PyArg_ParseTuple(args, "t#|zO:charmap_decode", &data, &size, &errors, &mapping)) return NULL; @@ -495,7 +495,7 @@ mbcs_decode(PyObject *self, const char *data; int size; const char *errors = NULL; - + if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode", &data, &size, &errors)) return NULL; @@ -548,7 +548,7 @@ unicode_internal_encode(PyObject *self, const char *errors = NULL; const char *data; int size; - + if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode", &obj, &errors)) return NULL; @@ -616,7 +616,7 @@ utf_8_encode(PyObject *self, /* This version provides access to the byteorder parameter of the builtin UTF-16 codecs as optional third argument. It defaults to 0 which means: use the native byte order and prepend the data with a - BOM mark. + BOM mark. */ @@ -704,7 +704,7 @@ unicode_escape_encode(PyObject *self, str = PyUnicode_FromObject(str); if (str == NULL) return NULL; - v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str), + v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str)), PyUnicode_GET_SIZE(str)); Py_DECREF(str); @@ -726,7 +726,7 @@ raw_unicode_escape_encode(PyObject *self, if (str == NULL) return NULL; v = codec_tuple(PyUnicode_EncodeRawUnicodeEscape( - PyUnicode_AS_UNICODE(str), + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str)), PyUnicode_GET_SIZE(str)); Py_DECREF(str); @@ -748,7 +748,7 @@ latin_1_encode(PyObject *self, if (str == NULL) return NULL; v = codec_tuple(PyUnicode_EncodeLatin1( - PyUnicode_AS_UNICODE(str), + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), errors), PyUnicode_GET_SIZE(str)); @@ -771,7 +771,7 @@ ascii_encode(PyObject *self, if (str == NULL) return NULL; v = codec_tuple(PyUnicode_EncodeASCII( - PyUnicode_AS_UNICODE(str), + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), errors), PyUnicode_GET_SIZE(str)); @@ -797,9 +797,9 @@ charmap_encode(PyObject *self, if (str == NULL) return NULL; v = codec_tuple(PyUnicode_EncodeCharmap( - PyUnicode_AS_UNICODE(str), + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), - mapping, + mapping, errors), PyUnicode_GET_SIZE(str)); Py_DECREF(str); @@ -823,7 +823,7 @@ mbcs_encode(PyObject *self, if (str == NULL) return NULL; v = codec_tuple(PyUnicode_EncodeMBCS( - PyUnicode_AS_UNICODE(str), + PyUnicode_AS_UNICODE(str), PyUnicode_GET_SIZE(str), errors), PyUnicode_GET_SIZE(str));