Пример #1
0
static PyObject *
_codecs_escape_decode_impl(PyObject *module, Py_buffer *data,
                           const char *errors)
/*[clinic end generated code: output=505200ba8056979a input=0018edfd99db714d]*/
{
    PyObject *decoded = PyBytes_DecodeEscape(data->buf, data->len,
                                             errors, 0, NULL);
    return codec_tuple(decoded, data->len);
}
Пример #2
0
/* --- String codecs ------------------------------------------------------ */
static PyObject *
escape_decode(PyObject *self,
              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;
    return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL),
                       size);
}
Пример #3
0
/* --- String codecs ------------------------------------------------------ */
static PyObject *
escape_decode(PyObject *self,
              PyObject *args)
{
    Py_buffer pbuf;
    const char *errors = NULL;
    PyObject *result;

    if (!PyArg_ParseTuple(args, "s*|z:escape_decode",
                          &pbuf, &errors))
        return NULL;
    result = codec_tuple(
            PyBytes_DecodeEscape(pbuf.buf, pbuf.len, errors, 0, NULL),
            pbuf.len);
    PyBuffer_Release(&pbuf);
    return result;
}