Mercurial > cpython-lru_cache-weakref
diff Modules/_codecsmodule.c @ 61465:e38335d4df91 2.6
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines
Untabify C files. Will watch buildbots.
........
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Sun, 09 May 2010 15:15:40 +0000 |
| parents | f3b26a729e82 |
| children | c1145e668d72 |
line wrap: on
line diff
--- a/Modules/_codecsmodule.c Sun May 09 14:07:57 2010 +0000 +++ b/Modules/_codecsmodule.c Sun May 09 15:15:40 2010 +0000 @@ -15,7 +15,7 @@ The builtin Unicode codecs use the following interface: <encoding>_encode(Unicode_object[,errors='strict']) -> - (string object, bytes consumed) + (string object, bytes consumed) <encoding>_decode(char_buffer_obj[,errors='strict']) -> (Unicode object, bytes consumed) @@ -96,11 +96,11 @@ #ifdef Py_USING_UNICODE if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); + encoding = PyUnicode_GetDefaultEncoding(); #else if (encoding == NULL) { - PyErr_SetString(PyExc_ValueError, "no encoding specified"); - return NULL; + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; } #endif @@ -130,11 +130,11 @@ #ifdef Py_USING_UNICODE if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); + encoding = PyUnicode_GetDefaultEncoding(); #else if (encoding == NULL) { - PyErr_SetString(PyExc_ValueError, "no encoding specified"); - return NULL; + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; } #endif @@ -146,7 +146,7 @@ static PyObject *codec_tuple(PyObject *unicode, - Py_ssize_t len) + Py_ssize_t len) { PyObject *v; if (unicode == NULL) @@ -159,44 +159,44 @@ /* --- String codecs ------------------------------------------------------ */ static PyObject * escape_decode(PyObject *self, - PyObject *args) + PyObject *args) { const char *errors = NULL; const char *data; Py_ssize_t size; if (!PyArg_ParseTuple(args, "s#|z:escape_decode", - &data, &size, &errors)) - return NULL; + &data, &size, &errors)) + return NULL; return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL), - size); + size); } static PyObject * escape_encode(PyObject *self, - PyObject *args) + PyObject *args) { - PyObject *str; - const char *errors = NULL; - char *buf; - Py_ssize_t len; + PyObject *str; + const char *errors = NULL; + char *buf; + Py_ssize_t len; - if (!PyArg_ParseTuple(args, "O!|z:escape_encode", - &PyString_Type, &str, &errors)) - return NULL; + if (!PyArg_ParseTuple(args, "O!|z:escape_encode", + &PyString_Type, &str, &errors)) + return NULL; - str = PyString_Repr(str, 0); - if (!str) - return NULL; + str = PyString_Repr(str, 0); + if (!str) + return NULL; - /* The string will be quoted. Unquote, similar to unicode-escape. */ - buf = PyString_AS_STRING (str); - len = PyString_GET_SIZE (str); - memmove(buf, buf+1, len-2); - if (_PyString_Resize(&str, len-2) < 0) - return NULL; - - return codec_tuple(str, PyString_Size(str)); + /* The string will be quoted. Unquote, similar to unicode-escape. */ + buf = PyString_AS_STRING (str); + len = PyString_GET_SIZE (str); + memmove(buf, buf+1, len-2); + if (_PyString_Resize(&str, len-2) < 0) + return NULL; + + return codec_tuple(str, PyString_Size(str)); } #ifdef Py_USING_UNICODE @@ -204,7 +204,7 @@ static PyObject * unicode_internal_decode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *obj; const char *errors = NULL; @@ -212,19 +212,19 @@ Py_ssize_t size; if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode", - &obj, &errors)) - return NULL; + &obj, &errors)) + return NULL; if (PyUnicode_Check(obj)) { - Py_INCREF(obj); - return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); + Py_INCREF(obj); + return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); } else { - if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) - return NULL; + if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) + return NULL; - return codec_tuple(_PyUnicode_DecodeUnicodeInternal(data, size, errors), - size); + return codec_tuple(_PyUnicode_DecodeUnicodeInternal(data, size, errors), + size); } } @@ -232,20 +232,20 @@ utf_7_decode(PyObject *self, PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int final = 0; Py_ssize_t consumed; PyObject *decoded = NULL; if (!PyArg_ParseTuple(args, "s*|zi:utf_7_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; decoded = PyUnicode_DecodeUTF7Stateful(pbuf.buf, pbuf.len, errors, - final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) return NULL; return codec_tuple(decoded, consumed); @@ -253,32 +253,32 @@ static PyObject * utf_8_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int final = 0; Py_ssize_t consumed; PyObject *decoded = NULL; if (!PyArg_ParseTuple(args, "s*|zi:utf_8_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; decoded = PyUnicode_DecodeUTF8Stateful(pbuf.buf, pbuf.len, errors, - final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } static PyObject * utf_16_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 0; int final = 0; @@ -286,22 +286,22 @@ PyObject *decoded; if (!PyArg_ParseTuple(args, "s*|zi:utf_16_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } static PyObject * utf_16_le_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = -1; int final = 0; @@ -309,23 +309,23 @@ PyObject *decoded = NULL; if (!PyArg_ParseTuple(args, "s*|zi:utf_16_le_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } static PyObject * utf_16_be_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 1; int final = 0; @@ -333,15 +333,15 @@ PyObject *decoded = NULL; if (!PyArg_ParseTuple(args, "s*|zi:utf_16_be_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } @@ -355,9 +355,9 @@ static PyObject * utf_16_ex_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 0; PyObject *unicode, *tuple; @@ -365,14 +365,14 @@ Py_ssize_t consumed; if (!PyArg_ParseTuple(args, "s*|zii:utf_16_ex_decode", - &pbuf, &errors, &byteorder, &final)) - return NULL; + &pbuf, &errors, &byteorder, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ unicode = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (unicode == NULL) - return NULL; + return NULL; tuple = Py_BuildValue("Oni", unicode, consumed, byteorder); Py_DECREF(unicode); return tuple; @@ -380,9 +380,9 @@ static PyObject * utf_32_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 0; int final = 0; @@ -390,22 +390,22 @@ PyObject *decoded; if (!PyArg_ParseTuple(args, "s*|zi:utf_32_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } static PyObject * utf_32_le_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = -1; int final = 0; @@ -413,22 +413,22 @@ PyObject *decoded; if (!PyArg_ParseTuple(args, "s*|zi:utf_32_le_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } static PyObject * utf_32_be_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 1; int final = 0; @@ -436,14 +436,14 @@ PyObject *decoded; if (!PyArg_ParseTuple(args, "s*|zi:utf_32_be_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } @@ -457,9 +457,9 @@ static PyObject * utf_32_ex_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int byteorder = 0; PyObject *unicode, *tuple; @@ -467,14 +467,14 @@ Py_ssize_t consumed; if (!PyArg_ParseTuple(args, "s*|zii:utf_32_ex_decode", - &pbuf, &errors, &byteorder, &final)) - return NULL; + &pbuf, &errors, &byteorder, &final)) + return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ unicode = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, - &byteorder, final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + &byteorder, final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (unicode == NULL) - return NULL; + return NULL; tuple = Py_BuildValue("Oni", unicode, consumed, byteorder); Py_DECREF(unicode); return tuple; @@ -482,114 +482,114 @@ static PyObject * unicode_escape_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; - PyObject *unicode; + PyObject *unicode; if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode", - &pbuf, &errors)) - return NULL; + &pbuf, &errors)) + return NULL; - unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors); - PyBuffer_Release(&pbuf); - return codec_tuple(unicode, pbuf.len); + unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors); + PyBuffer_Release(&pbuf); + return codec_tuple(unicode, pbuf.len); } static PyObject * raw_unicode_escape_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; - PyObject *unicode; + PyObject *unicode; if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode", - &pbuf, &errors)) - return NULL; + &pbuf, &errors)) + return NULL; - unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors); - PyBuffer_Release(&pbuf); - return codec_tuple(unicode, pbuf.len); + unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors); + PyBuffer_Release(&pbuf); + return codec_tuple(unicode, pbuf.len); } static PyObject * latin_1_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; - PyObject *unicode; + Py_buffer pbuf; + PyObject *unicode; const char *errors = NULL; if (!PyArg_ParseTuple(args, "s*|z:latin_1_decode", - &pbuf, &errors)) - return NULL; + &pbuf, &errors)) + return NULL; - unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors); - PyBuffer_Release(&pbuf); - return codec_tuple(unicode, pbuf.len); + unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors); + PyBuffer_Release(&pbuf); + return codec_tuple(unicode, pbuf.len); } static PyObject * ascii_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; - PyObject *unicode; + Py_buffer pbuf; + PyObject *unicode; const char *errors = NULL; if (!PyArg_ParseTuple(args, "s*|z:ascii_decode", - &pbuf, &errors)) - return NULL; + &pbuf, &errors)) + return NULL; - unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors); - PyBuffer_Release(&pbuf); - return codec_tuple(unicode, pbuf.len); + unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors); + PyBuffer_Release(&pbuf); + return codec_tuple(unicode, pbuf.len); } static PyObject * charmap_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; - PyObject *unicode; + Py_buffer pbuf; + PyObject *unicode; const char *errors = NULL; PyObject *mapping = NULL; if (!PyArg_ParseTuple(args, "s*|zO:charmap_decode", - &pbuf, &errors, &mapping)) - return NULL; + &pbuf, &errors, &mapping)) + return NULL; if (mapping == Py_None) - mapping = NULL; + mapping = NULL; - unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors); - PyBuffer_Release(&pbuf); - return codec_tuple(unicode, pbuf.len); + unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors); + PyBuffer_Release(&pbuf); + return codec_tuple(unicode, pbuf.len); } #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) static PyObject * mbcs_decode(PyObject *self, - PyObject *args) + PyObject *args) { - Py_buffer pbuf; + Py_buffer pbuf; const char *errors = NULL; int final = 0; Py_ssize_t consumed; PyObject *decoded = NULL; if (!PyArg_ParseTuple(args, "s*|zi:mbcs_decode", - &pbuf, &errors, &final)) - return NULL; + &pbuf, &errors, &final)) + return NULL; consumed = pbuf.len; decoded = PyUnicode_DecodeMBCSStateful(pbuf.buf, pbuf.len, errors, - final ? NULL : &consumed); - PyBuffer_Release(&pbuf); + final ? NULL : &consumed); + PyBuffer_Release(&pbuf); if (decoded == NULL) - return NULL; + return NULL; return codec_tuple(decoded, consumed); } @@ -599,39 +599,39 @@ static PyObject * readbuffer_encode(PyObject *self, - PyObject *args) + PyObject *args) { const char *data; Py_ssize_t size; const char *errors = NULL; if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode", - &data, &size, &errors)) - return NULL; + &data, &size, &errors)) + return NULL; return codec_tuple(PyString_FromStringAndSize(data, size), - size); + size); } static PyObject * charbuffer_encode(PyObject *self, - PyObject *args) + PyObject *args) { const char *data; Py_ssize_t size; const char *errors = NULL; if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode", - &data, &size, &errors)) - return NULL; + &data, &size, &errors)) + return NULL; return codec_tuple(PyString_FromStringAndSize(data, size), - size); + size); } static PyObject * unicode_internal_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *obj; const char *errors = NULL; @@ -639,65 +639,65 @@ Py_ssize_t size; if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode", - &obj, &errors)) - return NULL; + &obj, &errors)) + return NULL; if (PyUnicode_Check(obj)) { - data = PyUnicode_AS_DATA(obj); - size = PyUnicode_GET_DATA_SIZE(obj); - return codec_tuple(PyString_FromStringAndSize(data, size), - size); + data = PyUnicode_AS_DATA(obj); + size = PyUnicode_GET_DATA_SIZE(obj); + return codec_tuple(PyString_FromStringAndSize(data, size), + size); } else { - if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) - return NULL; - return codec_tuple(PyString_FromStringAndSize(data, size), - size); + if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) + return NULL; + return codec_tuple(PyString_FromStringAndSize(data, size), + size); } } static PyObject * utf_7_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_7_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - 0, - 0, - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + 0, + 0, + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * utf_8_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_8_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } @@ -711,70 +711,70 @@ static PyObject * utf_16_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; int byteorder = 0; if (!PyArg_ParseTuple(args, "O|zi:utf_16_encode", - &str, &errors, &byteorder)) - return NULL; + &str, &errors, &byteorder)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - byteorder), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + byteorder), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * utf_16_le_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_16_le_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - -1), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + -1), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * utf_16_be_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_16_be_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - +1), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + +1), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } @@ -788,186 +788,186 @@ static PyObject * utf_32_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; int byteorder = 0; if (!PyArg_ParseTuple(args, "O|zi:utf_32_encode", - &str, &errors, &byteorder)) - return NULL; + &str, &errors, &byteorder)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - byteorder), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + byteorder), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * utf_32_le_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_32_le_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - -1), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + -1), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * utf_32_be_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:utf_32_be_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - +1), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str), + errors, + +1), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * unicode_escape_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:unicode_escape_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str)), - PyUnicode_GET_SIZE(str)); + PyUnicode_GET_SIZE(str)), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * raw_unicode_escape_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:raw_unicode_escape_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeRawUnicodeEscape( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str)), - PyUnicode_GET_SIZE(str)); + PyUnicode_AS_UNICODE(str), + PyUnicode_GET_SIZE(str)), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * latin_1_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:latin_1_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeLatin1( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_AS_UNICODE(str), + PyUnicode_GET_SIZE(str), + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * ascii_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:ascii_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeASCII( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_AS_UNICODE(str), + PyUnicode_GET_SIZE(str), + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } static PyObject * charmap_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; PyObject *mapping = NULL; if (!PyArg_ParseTuple(args, "O|zO:charmap_encode", - &str, &errors, &mapping)) - return NULL; + &str, &errors, &mapping)) + return NULL; if (mapping == Py_None) - mapping = NULL; + mapping = NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeCharmap( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - mapping, - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_AS_UNICODE(str), + PyUnicode_GET_SIZE(str), + mapping, + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } @@ -985,23 +985,23 @@ static PyObject * mbcs_encode(PyObject *self, - PyObject *args) + PyObject *args) { PyObject *str, *v; const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z:mbcs_encode", - &str, &errors)) - return NULL; + &str, &errors)) + return NULL; str = PyUnicode_FromObject(str); if (str == NULL) - return NULL; + return NULL; v = codec_tuple(PyUnicode_EncodeMBCS( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); + PyUnicode_AS_UNICODE(str), + PyUnicode_GET_SIZE(str), + errors), + PyUnicode_GET_SIZE(str)); Py_DECREF(str); return v; } @@ -1026,8 +1026,8 @@ PyObject *handler; if (!PyArg_ParseTuple(args, "sO:register_error", - &name, &handler)) - return NULL; + &name, &handler)) + return NULL; if (PyCodec_RegisterError(name, handler)) return NULL; Py_RETURN_NONE; @@ -1044,68 +1044,68 @@ const char *name; if (!PyArg_ParseTuple(args, "s:lookup_error", - &name)) - return NULL; + &name)) + return NULL; return PyCodec_LookupError(name); } /* --- Module API --------------------------------------------------------- */ static PyMethodDef _codecs_functions[] = { - {"register", codec_register, METH_O, + {"register", codec_register, METH_O, register__doc__}, - {"lookup", codec_lookup, METH_VARARGS, + {"lookup", codec_lookup, METH_VARARGS, lookup__doc__}, - {"encode", codec_encode, METH_VARARGS, - encode__doc__}, - {"decode", codec_decode, METH_VARARGS, - decode__doc__}, - {"escape_encode", escape_encode, METH_VARARGS}, - {"escape_decode", escape_decode, METH_VARARGS}, + {"encode", codec_encode, METH_VARARGS, + encode__doc__}, + {"decode", codec_decode, METH_VARARGS, + decode__doc__}, + {"escape_encode", escape_encode, METH_VARARGS}, + {"escape_decode", escape_decode, METH_VARARGS}, #ifdef Py_USING_UNICODE - {"utf_8_encode", utf_8_encode, METH_VARARGS}, - {"utf_8_decode", utf_8_decode, METH_VARARGS}, - {"utf_7_encode", utf_7_encode, METH_VARARGS}, - {"utf_7_decode", utf_7_decode, METH_VARARGS}, - {"utf_16_encode", utf_16_encode, METH_VARARGS}, - {"utf_16_le_encode", utf_16_le_encode, METH_VARARGS}, - {"utf_16_be_encode", utf_16_be_encode, METH_VARARGS}, - {"utf_16_decode", utf_16_decode, METH_VARARGS}, - {"utf_16_le_decode", utf_16_le_decode, METH_VARARGS}, - {"utf_16_be_decode", utf_16_be_decode, METH_VARARGS}, - {"utf_16_ex_decode", utf_16_ex_decode, METH_VARARGS}, - {"utf_32_encode", utf_32_encode, METH_VARARGS}, - {"utf_32_le_encode", utf_32_le_encode, METH_VARARGS}, - {"utf_32_be_encode", utf_32_be_encode, METH_VARARGS}, - {"utf_32_decode", utf_32_decode, METH_VARARGS}, - {"utf_32_le_decode", utf_32_le_decode, METH_VARARGS}, - {"utf_32_be_decode", utf_32_be_decode, METH_VARARGS}, - {"utf_32_ex_decode", utf_32_ex_decode, METH_VARARGS}, - {"unicode_escape_encode", unicode_escape_encode, METH_VARARGS}, - {"unicode_escape_decode", unicode_escape_decode, METH_VARARGS}, - {"unicode_internal_encode", unicode_internal_encode, METH_VARARGS}, - {"unicode_internal_decode", unicode_internal_decode, METH_VARARGS}, - {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS}, - {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS}, - {"latin_1_encode", latin_1_encode, METH_VARARGS}, - {"latin_1_decode", latin_1_decode, METH_VARARGS}, - {"ascii_encode", ascii_encode, METH_VARARGS}, - {"ascii_decode", ascii_decode, METH_VARARGS}, - {"charmap_encode", charmap_encode, METH_VARARGS}, - {"charmap_decode", charmap_decode, METH_VARARGS}, - {"charmap_build", charmap_build, METH_VARARGS}, - {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, - {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, + {"utf_8_encode", utf_8_encode, METH_VARARGS}, + {"utf_8_decode", utf_8_decode, METH_VARARGS}, + {"utf_7_encode", utf_7_encode, METH_VARARGS}, + {"utf_7_decode", utf_7_decode, METH_VARARGS}, + {"utf_16_encode", utf_16_encode, METH_VARARGS}, + {"utf_16_le_encode", utf_16_le_encode, METH_VARARGS}, + {"utf_16_be_encode", utf_16_be_encode, METH_VARARGS}, + {"utf_16_decode", utf_16_decode, METH_VARARGS}, + {"utf_16_le_decode", utf_16_le_decode, METH_VARARGS}, + {"utf_16_be_decode", utf_16_be_decode, METH_VARARGS}, + {"utf_16_ex_decode", utf_16_ex_decode, METH_VARARGS}, + {"utf_32_encode", utf_32_encode, METH_VARARGS}, + {"utf_32_le_encode", utf_32_le_encode, METH_VARARGS}, + {"utf_32_be_encode", utf_32_be_encode, METH_VARARGS}, + {"utf_32_decode", utf_32_decode, METH_VARARGS}, + {"utf_32_le_decode", utf_32_le_decode, METH_VARARGS}, + {"utf_32_be_decode", utf_32_be_decode, METH_VARARGS}, + {"utf_32_ex_decode", utf_32_ex_decode, METH_VARARGS}, + {"unicode_escape_encode", unicode_escape_encode, METH_VARARGS}, + {"unicode_escape_decode", unicode_escape_decode, METH_VARARGS}, + {"unicode_internal_encode", unicode_internal_encode, METH_VARARGS}, + {"unicode_internal_decode", unicode_internal_decode, METH_VARARGS}, + {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS}, + {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS}, + {"latin_1_encode", latin_1_encode, METH_VARARGS}, + {"latin_1_decode", latin_1_decode, METH_VARARGS}, + {"ascii_encode", ascii_encode, METH_VARARGS}, + {"ascii_decode", ascii_decode, METH_VARARGS}, + {"charmap_encode", charmap_encode, METH_VARARGS}, + {"charmap_decode", charmap_decode, METH_VARARGS}, + {"charmap_build", charmap_build, METH_VARARGS}, + {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, + {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - {"mbcs_encode", mbcs_encode, METH_VARARGS}, - {"mbcs_decode", mbcs_decode, METH_VARARGS}, + {"mbcs_encode", mbcs_encode, METH_VARARGS}, + {"mbcs_decode", mbcs_decode, METH_VARARGS}, #endif #endif /* Py_USING_UNICODE */ - {"register_error", register_error, METH_VARARGS, + {"register_error", register_error, METH_VARARGS, register_error__doc__}, - {"lookup_error", lookup_error, METH_VARARGS, + {"lookup_error", lookup_error, METH_VARARGS, lookup_error__doc__}, - {NULL, NULL} /* sentinel */ + {NULL, NULL} /* sentinel */ }; PyMODINIT_FUNC
