Back to index

python3.2  3.2.2
Defines | Functions | Variables
_codecsmodule.c File Reference
#include "Python.h"

Go to the source code of this file.

Defines

#define PY_SSIZE_T_CLEAN

Functions

 PyDoc_STRVAR (register__doc__,"register(search_function)\n\ \n\ Register a codec search function. Search functions are expected to take\n\ one argument, the encoding name in all lower case letters, and return\n\ a tuple of functions (encoder, decoder, stream_reader, stream_writer)\n\ (or a CodecInfo object).")
static PyObjectcodec_register (PyObject *self, PyObject *search_function)
 PyDoc_STRVAR (lookup__doc__,"lookup(encoding) -> CodecInfo\n\ \n\ Looks up a codec tuple in the Python codec registry and returns\n\ a CodecInfo object.")
static PyObjectcodec_lookup (PyObject *self, PyObject *args)
 PyDoc_STRVAR (encode__doc__,"encode(obj, [encoding[,errors]]) -> object\n\ \n\ Encodes obj using the codec registered for encoding. encoding defaults\n\ to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ a ValueError. Other possible values are 'ignore', 'replace' and\n\ 'xmlcharrefreplace' as well as any other name registered with\n\ codecs.register_error that can handle ValueErrors.")
static PyObjectcodec_encode (PyObject *self, PyObject *args)
 PyDoc_STRVAR (decode__doc__,"decode(obj, [encoding[,errors]]) -> object\n\ \n\ Decodes obj using the codec registered for encoding. encoding defaults\n\ to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ a ValueError. Other possible values are 'ignore' and 'replace'\n\ as well as any other name registered with codecs.register_error that is\n\ able to handle ValueErrors.")
static PyObjectcodec_decode (PyObject *self, PyObject *args)
static PyObjectcodec_tuple (PyObject *unicode, Py_ssize_t len)
static PyObjectescape_decode (PyObject *self, PyObject *args)
static PyObjectescape_encode (PyObject *self, PyObject *args)
static PyObjectunicode_internal_decode (PyObject *self, PyObject *args)
static PyObjectutf_7_decode (PyObject *self, PyObject *args)
static PyObjectutf_8_decode (PyObject *self, PyObject *args)
static PyObjectutf_16_decode (PyObject *self, PyObject *args)
static PyObjectutf_16_le_decode (PyObject *self, PyObject *args)
static PyObjectutf_16_be_decode (PyObject *self, PyObject *args)
static PyObjectutf_16_ex_decode (PyObject *self, PyObject *args)
static PyObjectutf_32_decode (PyObject *self, PyObject *args)
static PyObjectutf_32_le_decode (PyObject *self, PyObject *args)
static PyObjectutf_32_be_decode (PyObject *self, PyObject *args)
static PyObjectutf_32_ex_decode (PyObject *self, PyObject *args)
static PyObjectunicode_escape_decode (PyObject *self, PyObject *args)
static PyObjectraw_unicode_escape_decode (PyObject *self, PyObject *args)
static PyObjectlatin_1_decode (PyObject *self, PyObject *args)
static PyObjectascii_decode (PyObject *self, PyObject *args)
static PyObjectcharmap_decode (PyObject *self, PyObject *args)
static PyObjectreadbuffer_encode (PyObject *self, PyObject *args)
static PyObjectunicode_internal_encode (PyObject *self, PyObject *args)
static PyObjectutf_7_encode (PyObject *self, PyObject *args)
static PyObjectutf_8_encode (PyObject *self, PyObject *args)
static PyObjectutf_16_encode (PyObject *self, PyObject *args)
static PyObjectutf_16_le_encode (PyObject *self, PyObject *args)
static PyObjectutf_16_be_encode (PyObject *self, PyObject *args)
static PyObjectutf_32_encode (PyObject *self, PyObject *args)
static PyObjectutf_32_le_encode (PyObject *self, PyObject *args)
static PyObjectutf_32_be_encode (PyObject *self, PyObject *args)
static PyObjectunicode_escape_encode (PyObject *self, PyObject *args)
static PyObjectraw_unicode_escape_encode (PyObject *self, PyObject *args)
static PyObjectlatin_1_encode (PyObject *self, PyObject *args)
static PyObjectascii_encode (PyObject *self, PyObject *args)
static PyObjectcharmap_encode (PyObject *self, PyObject *args)
static PyObjectcharmap_build (PyObject *self, PyObject *args)
 PyDoc_STRVAR (register_error__doc__,"register_error(errors, handler)\n\ \n\ Register the specified error handler under the name\n\ errors. handler must be a callable object, that\n\ will be called with an exception instance containing\n\ information about the location of the encoding/decoding\n\ error and must return a (replacement, new position) tuple.")
static PyObjectregister_error (PyObject *self, PyObject *args)
 PyDoc_STRVAR (lookup_error__doc__,"lookup_error(errors) -> handler\n\ \n\ Return the error handler for the specified error handling name\n\ or raise a LookupError, if no handler exists under this name.")
static PyObjectlookup_error (PyObject *self, PyObject *args)
PyMODINIT_FUNC PyInit__codecs (void)

Variables

static PyMethodDef _codecs_functions []
static struct PyModuleDef

Define Documentation

Definition at line 38 of file _codecsmodule.c.


Function Documentation

static PyObject* ascii_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 555 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    PyObject *unicode;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "y*|z:ascii_decode",
                          &pbuf, &errors))
        return NULL;

    unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors);
    PyBuffer_Release(&pbuf);
    return codec_tuple(unicode, pbuf.len);
}

Here is the call graph for this function:

static PyObject* ascii_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 934 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:ascii_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeASCII(
                               PyUnicode_AS_UNICODE(str),
                               PyUnicode_GET_SIZE(str),
                               errors),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* charmap_build ( PyObject self,
PyObject args 
) [static]

Definition at line 984 of file _codecsmodule.c.

{
    PyObject *map;
    if (!PyArg_ParseTuple(args, "U:charmap_build", &map))
        return NULL;
    return PyUnicode_BuildEncodingMap(map);
}

Here is the call graph for this function:

static PyObject* charmap_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 572 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    PyObject *unicode;
    const char *errors = NULL;
    PyObject *mapping = NULL;

    if (!PyArg_ParseTuple(args, "y*|zO:charmap_decode",
                          &pbuf, &errors, &mapping))
        return NULL;
    if (mapping == Py_None)
        mapping = NULL;

    unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
    PyBuffer_Release(&pbuf);
    return codec_tuple(unicode, pbuf.len);
}

Here is the call graph for this function:

static PyObject* charmap_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 957 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;
    PyObject *mapping = NULL;

    if (!PyArg_ParseTuple(args, "O|zO:charmap_encode",
                          &str, &errors, &mapping))
        return NULL;
    if (mapping == Py_None)
        mapping = NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeCharmap(
                               PyUnicode_AS_UNICODE(str),
                               PyUnicode_GET_SIZE(str),
                               mapping,
                               errors),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* codec_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 115 of file _codecsmodule.c.

{
    const char *encoding = NULL;
    const char *errors = NULL;
    PyObject *v;

    if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
        return NULL;

    if (encoding == NULL)
        encoding = PyUnicode_GetDefaultEncoding();

    /* Decode via the codec registry */
    return PyCodec_Decode(v, encoding, errors);
}

Here is the call graph for this function:

static PyObject* codec_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 88 of file _codecsmodule.c.

{
    const char *encoding = NULL;
    const char *errors = NULL;
    PyObject *v;

    if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
        return NULL;

    if (encoding == NULL)
        encoding = PyUnicode_GetDefaultEncoding();

    /* Encode via the codec registry */
    return PyCodec_Encode(v, encoding, errors);
}

Here is the call graph for this function:

static PyObject* codec_lookup ( PyObject self,
PyObject args 
) [static]

Definition at line 67 of file _codecsmodule.c.

{
    char *encoding;

    if (!PyArg_ParseTuple(args, "s:lookup", &encoding))
        return NULL;

    return _PyCodec_Lookup(encoding);
}

Here is the call graph for this function:

static PyObject* codec_register ( PyObject self,
PyObject search_function 
) [static]

Definition at line 52 of file _codecsmodule.c.

{
    if (PyCodec_Register(search_function))
        return NULL;

    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* codec_tuple ( PyObject unicode,
Py_ssize_t  len 
) [static]

Definition at line 134 of file _codecsmodule.c.

{
    PyObject *v;
    if (unicode == NULL)
        return NULL;
    v = Py_BuildValue("On", unicode, len);
    Py_DECREF(unicode);
    return v;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* escape_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 147 of file _codecsmodule.c.

{
    const char *errors = NULL;
    const char *data;
    Py_ssize_t size;

    if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
                          &data, &size, &errors))
        return NULL;
    return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL),
                       size);
}

Here is the call graph for this function:

static PyObject* escape_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 162 of file _codecsmodule.c.

{
    static const char *hexdigits = "0123456789abcdef";
    PyObject *str;
    Py_ssize_t size;
    Py_ssize_t newsize;
    const char *errors = NULL;
    PyObject *v;

    if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
                          &PyBytes_Type, &str, &errors))
        return NULL;

    size = PyBytes_GET_SIZE(str);
    newsize = 4*size;
    if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
        PyErr_SetString(PyExc_OverflowError,
            "string is too large to encode");
            return NULL;
    }
    v = PyBytes_FromStringAndSize(NULL, newsize);

    if (v == NULL) {
        return NULL;
    }
    else {
        register Py_ssize_t i;
        register char c;
        register char *p = PyBytes_AS_STRING(v);

        for (i = 0; i < size; i++) {
            /* There's at least enough room for a hex escape */
            assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4);
            c = PyBytes_AS_STRING(str)[i];
            if (c == '\'' || c == '\\')
                *p++ = '\\', *p++ = c;
            else if (c == '\t')
                *p++ = '\\', *p++ = 't';
            else if (c == '\n')
                *p++ = '\\', *p++ = 'n';
            else if (c == '\r')
                *p++ = '\\', *p++ = 'r';
            else if (c < ' ' || c >= 0x7f) {
                *p++ = '\\';
                *p++ = 'x';
                *p++ = hexdigits[(c & 0xf0) >> 4];
                *p++ = hexdigits[c & 0xf];
            }
            else
                *p++ = c;
        }
        *p = '\0';
        if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) {
            return NULL;
        }
    }

    return codec_tuple(v, size);
}

Here is the call graph for this function:

static PyObject* latin_1_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 538 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    PyObject *unicode;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode",
                          &pbuf, &errors))
        return NULL;

    unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors);
    PyBuffer_Release(&pbuf);
    return codec_tuple(unicode, pbuf.len);
}

Here is the call graph for this function:

static PyObject* latin_1_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 911 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:latin_1_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeLatin1(
                               PyUnicode_AS_UNICODE(str),
                               PyUnicode_GET_SIZE(str),
                               errors),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* lookup_error ( PyObject self,
PyObject args 
) [static]

Definition at line 1049 of file _codecsmodule.c.

{
    const char *name;

    if (!PyArg_ParseTuple(args, "s:lookup_error",
                          &name))
        return NULL;
    return PyCodec_LookupError(name);
}

Here is the call graph for this function:

PyDoc_STRVAR ( register__doc__  ,
"register(search_function)\n\\n\Register a codec search function. Search functions are expected to take\n\one  argument,
the encoding name in all lower case  letters,
and return\n\a tuple of functions(encoder, decoder, stream_reader, stream_writer)\n\(or a CodecInfo object)."   
)
PyDoc_STRVAR ( lookup__doc__  ,
"lookup(encoding) -> CodecInfo\n\\n\Looks up a codec tuple in the Python codec registry and returns\n\a CodecInfo object."   
)
PyDoc_STRVAR ( encode__doc__  ,
"encode(obj, [encoding[,errors]]) -> object\n\\n\Encodes obj using the codec registered for encoding. encoding defaults\n\to the default encoding. errors may be given to set a different error\n\handling scheme. Default is 'strict' meaning that encoding errors raise\n\a ValueError. Other possible values are 'ignore'  ,
'replace'and\n\'xmlcharrefreplace'as well as any other name registered with\n\codecs.register_error that can handle ValueErrors."   
)
PyDoc_STRVAR ( decode__doc__  ,
"decode(obj, [encoding[,errors]]) -> object\n\\n\Decodes obj using the codec registered for encoding. encoding defaults\n\to the default encoding. errors may be given to set a different error\n\handling scheme. Default is 'strict' meaning that encoding errors raise\n\a ValueError. Other possible values are 'ignore' and 'replace'\n\as well as any other name registered with codecs.register_error that is\n\able to handle ValueErrors."   
)
PyDoc_STRVAR ( register_error__doc__  ,
"register_error(errors, handler)\n\\n\Register the specified error handler under the name\n\errors. handler must be a callable  object,
that\n\will be called with an exception instance containing\n\information about the location of the encoding/decoding\n\error and must return a(replacement, new position) tuple."   
)
PyDoc_STRVAR ( lookup_error__doc__  ,
"lookup_error(errors) -> handler\n\\n\Return the error handler for the specified error handling name\n\or raise a  LookupError,
if no handler exists under this name."   
)

Definition at line 1128 of file _codecsmodule.c.

{
        return PyModule_Create(&codecsmodule);
}
static PyObject* raw_unicode_escape_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 521 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    PyObject *unicode;

    if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
                          &pbuf, &errors))
        return NULL;

    unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors);
    PyBuffer_Release(&pbuf);
    return codec_tuple(unicode, pbuf.len);
}

Here is the call graph for this function:

static PyObject* raw_unicode_escape_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 889 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:raw_unicode_escape_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeRawUnicodeEscape(
                               PyUnicode_AS_UNICODE(str),
                               PyUnicode_GET_SIZE(str)),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* readbuffer_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 621 of file _codecsmodule.c.

{
    Py_buffer pdata;
    const char *data;
    Py_ssize_t size;
    const char *errors = NULL;
    PyObject *result;

    if (!PyArg_ParseTuple(args, "s*|z:readbuffer_encode",
                          &pdata, &errors))
        return NULL;
    data = pdata.buf;
    size = pdata.len;

    result = PyBytes_FromStringAndSize(data, size);
    PyBuffer_Release(&pdata);
    return codec_tuple(result, size);
}

Here is the call graph for this function:

static PyObject* register_error ( PyObject self,
PyObject args 
) [static]

Definition at line 1030 of file _codecsmodule.c.

{
    const char *name;
    PyObject *handler;

    if (!PyArg_ParseTuple(args, "sO:register_error",
                          &name, &handler))
        return NULL;
    if (PyCodec_RegisterError(name, handler))
        return NULL;
    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* unicode_escape_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 504 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
        PyObject *unicode;

    if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode",
                          &pbuf, &errors))
        return NULL;

    unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors);
    PyBuffer_Release(&pbuf);
    return codec_tuple(unicode, pbuf.len);
}

Here is the call graph for this function:

static PyObject* unicode_escape_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 868 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:unicode_escape_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str),
                                                  PyUnicode_GET_SIZE(str)),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* unicode_internal_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 226 of file _codecsmodule.c.

{
    PyObject *obj;
    const char *errors = NULL;
    const char *data;
    Py_ssize_t size;

    if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
                          &obj, &errors))
        return NULL;

    if (PyUnicode_Check(obj)) {
        Py_INCREF(obj);
        return codec_tuple(obj, PyUnicode_GET_SIZE(obj));
    }
    else {
        if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
            return NULL;

        return codec_tuple(_PyUnicode_DecodeUnicodeInternal(data, size, errors),
                           size);
    }
}

Here is the call graph for this function:

static PyObject* unicode_internal_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 642 of file _codecsmodule.c.

{
    PyObject *obj;
    const char *errors = NULL;
    const char *data;
    Py_ssize_t size;

    if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
                          &obj, &errors))
        return NULL;

    if (PyUnicode_Check(obj)) {
        data = PyUnicode_AS_DATA(obj);
        size = PyUnicode_GET_DATA_SIZE(obj);
        return codec_tuple(PyBytes_FromStringAndSize(data, size),
                           PyUnicode_GET_SIZE(obj));
    }
    else {
        if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
            return NULL;
        return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
    }
}

Here is the call graph for this function:

static PyObject* utf_16_be_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 345 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 1;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded = NULL;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_16_be_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 768 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_16_be_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str),
                                          PyUnicode_GET_SIZE(str),
                                          errors,
                                          +1),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_16_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 298 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 0;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_16_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 721 of file _codecsmodule.c.

{
    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 = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str),
                                          PyUnicode_GET_SIZE(str),
                                          errors,
                                          byteorder),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_16_ex_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 377 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 0;
    PyObject *unicode, *tuple;
    int final = 0;
    Py_ssize_t consumed;

    if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode",
                          &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);
    if (unicode == NULL)
        return NULL;
    tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
    Py_DECREF(unicode);
    return tuple;
}

Here is the call graph for this function:

static PyObject* utf_16_le_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 321 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = -1;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded = NULL;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_16_le_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 745 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_16_le_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str),
                                             PyUnicode_GET_SIZE(str),
                                             errors,
                                             -1),
                       PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_32_be_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 448 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 1;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_32_be_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 845 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_32_be_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str),
                                          PyUnicode_GET_SIZE(str),
                                          errors,
                                          +1),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_32_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 402 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 0;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_32_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 798 of file _codecsmodule.c.

{
    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 = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str),
                                          PyUnicode_GET_SIZE(str),
                                          errors,
                                          byteorder),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_32_ex_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 479 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = 0;
    PyObject *unicode, *tuple;
    int final = 0;
    Py_ssize_t consumed;

    if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode",
                          &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);
    if (unicode == NULL)
        return NULL;
    tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
    Py_DECREF(unicode);
    return tuple;
}

Here is the call graph for this function:

static PyObject* utf_32_le_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 425 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int byteorder = -1;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode",
                          &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);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_32_le_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 822 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_32_le_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str),
                                             PyUnicode_GET_SIZE(str),
                                             errors,
                                             -1),
                       PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_7_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 252 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded = NULL;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode",
                          &pbuf, &errors, &final))
        return NULL;
    consumed = pbuf.len;

    decoded = PyUnicode_DecodeUTF7Stateful(pbuf.buf, pbuf.len, errors,
                                           final ? NULL : &consumed);
    PyBuffer_Release(&pbuf);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_7_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 668 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_7_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str),
                                         PyUnicode_GET_SIZE(str),
                                         0,
                                         0,
                                         errors),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:

static PyObject* utf_8_decode ( PyObject self,
PyObject args 
) [static]

Definition at line 275 of file _codecsmodule.c.

{
    Py_buffer pbuf;
    const char *errors = NULL;
    int final = 0;
    Py_ssize_t consumed;
    PyObject *decoded = NULL;

    if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode",
                          &pbuf, &errors, &final))
        return NULL;
    consumed = pbuf.len;

    decoded = PyUnicode_DecodeUTF8Stateful(pbuf.buf, pbuf.len, errors,
                                           final ? NULL : &consumed);
    PyBuffer_Release(&pbuf);
    if (decoded == NULL)
        return NULL;
    return codec_tuple(decoded, consumed);
}

Here is the call graph for this function:

static PyObject* utf_8_encode ( PyObject self,
PyObject args 
) [static]

Definition at line 692 of file _codecsmodule.c.

{
    PyObject *str, *v;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "O|z:utf_8_encode",
                          &str, &errors))
        return NULL;

    str = PyUnicode_FromObject(str);
    if (str == NULL)
        return NULL;
    v = codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str),
                                         PyUnicode_GET_SIZE(str),
                                         errors),
                    PyUnicode_GET_SIZE(str));
    Py_DECREF(str);
    return v;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 1061 of file _codecsmodule.c.

struct PyModuleDef [static]
Initial value:
 {
        PyModuleDef_HEAD_INIT,
        "_codecs",
        NULL,
        -1,
        _codecs_functions,
        NULL,
        NULL,
        NULL,
        NULL
}

Definition at line 1115 of file _codecsmodule.c.