cpython/Modules/_testlimitedcapi/unicode.c

#include "pyconfig.h"   // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
   // Need limited C API 3.14 to test PyUnicode_Equal()
#define Py_LIMITED_API
#endif

#include "parts.h"
#include "util.h"

#include <stddef.h>               // ptrdiff_t
#include <string.h>               // memset()


static PyObject *
codec_incrementalencoder(PyObject *self, PyObject *args)
{}

static PyObject *
codec_incrementaldecoder(PyObject *self, PyObject *args)
{}

static PyObject *
test_unicode_compare_with_ascii(PyObject *self, PyObject *Py_UNUSED(ignored))
{}

static PyObject *
test_widechar(PyObject *self, PyObject *Py_UNUSED(ignored))
{}


static PyObject *
unicode_copy(PyObject *unicode)
{}

/* Test PyUnicode_WriteChar() */
static PyObject *
unicode_writechar(PyObject *self, PyObject *args)
{}

static void
unicode_fill(PyObject *str, Py_ssize_t start, Py_ssize_t end, Py_UCS4 ch)
{}


/* Test PyUnicode_Resize() */
static PyObject *
unicode_resize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Append() */
static PyObject *
unicode_append(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AppendAndDel() */
static PyObject *
unicode_appendanddel(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_FromStringAndSize() */
static PyObject *
unicode_fromstringandsize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_FromString() */
static PyObject *
unicode_fromstring(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_Substring() */
static PyObject *
unicode_substring(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_GetLength() */
static PyObject *
unicode_getlength(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_ReadChar() */
static PyObject *
unicode_readchar(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_FromEncodedObject() */
static PyObject *
unicode_fromencodedobject(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_FromObject() */
static PyObject *
unicode_fromobject(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_InternInPlace() */
static PyObject *
unicode_interninplace(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_InternFromString() */
static PyObject *
unicode_internfromstring(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_FromWideChar() */
static PyObject *
unicode_fromwidechar(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsWideChar() */
static PyObject *
unicode_aswidechar(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsWideCharString() with NULL as buffer */
static PyObject *
unicode_aswidechar_null(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsWideCharString() */
static PyObject *
unicode_aswidecharstring(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsWideCharString() with NULL as the size address */
static PyObject *
unicode_aswidecharstring_null(PyObject *self, PyObject *args)
{}


/* Test PyUnicode_FromOrdinal() */
static PyObject *
unicode_fromordinal(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUTF8AndSize() */
static PyObject *
unicode_asutf8andsize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUTF8AndSize() with NULL as the size address */
static PyObject *
unicode_asutf8andsize_null(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_GetDefaultEncoding() */
static PyObject *
unicode_getdefaultencoding(PyObject *self, PyObject *Py_UNUSED(ignored))
{}

/* Test PyUnicode_Decode() */
static PyObject *
unicode_decode(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsEncodedString() */
static PyObject *
unicode_asencodedstring(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_BuildEncodingMap() */
static PyObject *
unicode_buildencodingmap(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeUTF7() */
static PyObject *
unicode_decodeutf7(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeUTF7Stateful() */
static PyObject *
unicode_decodeutf7stateful(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeUTF8() */
static PyObject *
unicode_decodeutf8(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeUTF8Stateful() */
static PyObject *
unicode_decodeutf8stateful(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUTF8String() */
static PyObject *
unicode_asutf8string(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeUTF32() */
static PyObject *
unicode_decodeutf32(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeUTF32Stateful() */
static PyObject *
unicode_decodeutf32stateful(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUTF32String() */
static PyObject *
unicode_asutf32string(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeUTF16() */
static PyObject *
unicode_decodeutf16(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeUTF16Stateful() */
static PyObject *
unicode_decodeutf16stateful(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUTF16String() */
static PyObject *
unicode_asutf16string(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeUnicodeEscape() */
static PyObject *
unicode_decodeunicodeescape(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsUnicodeEscapeString() */
static PyObject *
unicode_asunicodeescapestring(PyObject *self, PyObject *arg)
{}

static PyObject *
unicode_decoderawunicodeescape(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsRawUnicodeEscapeString() */
static PyObject *
unicode_asrawunicodeescapestring(PyObject *self, PyObject *arg)
{}

static PyObject *
unicode_decodelatin1(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsLatin1String() */
static PyObject *
unicode_aslatin1string(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeASCII() */
static PyObject *
unicode_decodeascii(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsASCIIString() */
static PyObject *
unicode_asasciistring(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_DecodeCharmap() */
static PyObject *
unicode_decodecharmap(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_AsCharmapString() */
static PyObject *
unicode_ascharmapstring(PyObject *self, PyObject *args)
{}

#ifdef MS_WINDOWS

/* Test PyUnicode_DecodeMBCS() */
static PyObject *
unicode_decodembcs(PyObject *self, PyObject *args)
{
    const char *data;
    Py_ssize_t size;
    const char *errors = NULL;

    if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
        return NULL;

    return PyUnicode_DecodeMBCS(data, size, errors);
}

/* Test PyUnicode_DecodeMBCSStateful() */
static PyObject *
unicode_decodembcsstateful(PyObject *self, PyObject *args)
{
    const char *data;
    Py_ssize_t size;
    const char *errors = NULL;
    Py_ssize_t consumed = UNINITIALIZED_SIZE;
    PyObject *result;

    if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
        return NULL;

    result = PyUnicode_DecodeMBCSStateful(data, size, errors, &consumed);
    if (!result) {
        assert(consumed == UNINITIALIZED_SIZE);
        return NULL;
    }
    return Py_BuildValue("(Nn)", result, consumed);
}

/* Test PyUnicode_DecodeCodePageStateful() */
static PyObject *
unicode_decodecodepagestateful(PyObject *self, PyObject *args)
{
    int code_page;
    const char *data;
    Py_ssize_t size;
    const char *errors = NULL;
    Py_ssize_t consumed = UNINITIALIZED_SIZE;
    PyObject *result;

    if (!PyArg_ParseTuple(args, "iy#|z", &code_page, &data, &size, &errors))
        return NULL;

    result = PyUnicode_DecodeCodePageStateful(code_page, data, size, errors, &consumed);
    if (!result) {
        assert(consumed == UNINITIALIZED_SIZE);
        return NULL;
    }
    return Py_BuildValue("(Nn)", result, consumed);
}

/* Test PyUnicode_AsMBCSString() */
static PyObject *
unicode_asmbcsstring(PyObject *self, PyObject *arg)
{
    NULLABLE(arg);
    return PyUnicode_AsMBCSString(arg);
}

/* Test PyUnicode_EncodeCodePage() */
static PyObject *
unicode_encodecodepage(PyObject *self, PyObject *args)
{
    int code_page;
    PyObject *unicode;
    const char *errors;

    if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors))
        return NULL;

    NULLABLE(unicode);
    return PyUnicode_EncodeCodePage(code_page, unicode, errors);
}

#endif /* MS_WINDOWS */

/* Test PyUnicode_DecodeLocaleAndSize() */
static PyObject *
unicode_decodelocaleandsize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeLocale() */
static PyObject *
unicode_decodelocale(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_EncodeLocale() */
static PyObject *
unicode_encodelocale(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeFSDefault() */
static PyObject *
unicode_decodefsdefault(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_DecodeFSDefaultAndSize() */
static PyObject *
unicode_decodefsdefaultandsize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_EncodeFSDefault() */
static PyObject *
unicode_encodefsdefault(PyObject *self, PyObject *arg)
{}

/* Test PyUnicode_Concat() */
static PyObject *
unicode_concat(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Split() */
static PyObject *
unicode_split(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_RSplit() */
static PyObject *
unicode_rsplit(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Splitlines() */
static PyObject *
unicode_splitlines(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Partition() */
static PyObject *
unicode_partition(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_RPartition() */
static PyObject *
unicode_rpartition(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Translate() */
static PyObject *
unicode_translate(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Join() */
static PyObject *
unicode_join(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Count() */
static PyObject *
unicode_count(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Find() */
static PyObject *
unicode_find(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Tailmatch() */
static PyObject *
unicode_tailmatch(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_FindChar() */
static PyObject *
unicode_findchar(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Replace() */
static PyObject *
unicode_replace(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Compare() */
static PyObject *
unicode_compare(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_CompareWithASCIIString() */
static PyObject *
unicode_comparewithasciistring(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_EqualToUTF8() */
static PyObject *
unicode_equaltoutf8(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_EqualToUTF8AndSize() */
static PyObject *
unicode_equaltoutf8andsize(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_RichCompare() */
static PyObject *
unicode_richcompare(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Format() */
static PyObject *
unicode_format(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_Contains() */
static PyObject *
unicode_contains(PyObject *self, PyObject *args)
{}

/* Test PyUnicode_IsIdentifier() */
static PyObject *
unicode_isidentifier(PyObject *self, PyObject *arg)
{}


static int
check_raised_systemerror(PyObject *result, char* msg)
{}

static PyObject *
test_string_from_format(PyObject *self, PyObject *Py_UNUSED(ignored))
{}


/* Test PyUnicode_Equal() */
static PyObject *
unicode_equal(PyObject *module, PyObject *args)
{}



static PyMethodDef TestMethods[] =;

int
_PyTestLimitedCAPI_Init_Unicode(PyObject *m)
{}