Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into capi-PyUnicode_DecodeUTF8Stateful
  • Loading branch information
serhiy-storchaka committed Nov 29, 2022
commit 3d23080bce9eae8b669718e79d4fbdf5f582a54f
131 changes: 131 additions & 0 deletions Modules/_testcapi/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,129 @@ unicode_decodeutf8stateful(PyObject *self, PyObject *args)
return Py_BuildValue("(Nn)", result, consumed);
}

/* Test PyUnicode_Concat() */
static PyObject *
unicode_concat(PyObject *self, PyObject *args)
{
PyObject *left;
PyObject *right;

if (!PyArg_ParseTuple(args, "OO", &left, &right))
return NULL;

NULLABLE(left);
NULLABLE(right);
return PyUnicode_Concat(left, right);
}

/* Test PyUnicode_Split() */
static PyObject *
unicode_split(PyObject *self, PyObject *args)
{
PyObject *s;
PyObject *sep;
Py_ssize_t maxsplit = -1;

if (!PyArg_ParseTuple(args, "OO|n", &s, &sep, &maxsplit))
return NULL;

NULLABLE(s);
NULLABLE(sep);
return PyUnicode_Split(s, sep, maxsplit);
}

/* Test PyUnicode_RSplit() */
static PyObject *
unicode_rsplit(PyObject *self, PyObject *args)
{
PyObject *s;
PyObject *sep;
Py_ssize_t maxsplit = -1;

if (!PyArg_ParseTuple(args, "OO|n", &s, &sep, &maxsplit))
return NULL;

NULLABLE(s);
NULLABLE(sep);
return PyUnicode_RSplit(s, sep, maxsplit);
}

/* Test PyUnicode_Splitlines() */
static PyObject *
unicode_splitlines(PyObject *self, PyObject *args)
{
PyObject *s;
int keepends = 0;

if (!PyArg_ParseTuple(args, "O|i", &s, &keepends))
return NULL;

NULLABLE(s);
return PyUnicode_Splitlines(s, keepends);
}

/* Test PyUnicode_Partition() */
static PyObject *
unicode_partition(PyObject *self, PyObject *args)
{
PyObject *s;
PyObject *sep;

if (!PyArg_ParseTuple(args, "OO", &s, &sep))
return NULL;

NULLABLE(s);
NULLABLE(sep);
return PyUnicode_Partition(s, sep);
}

/* Test PyUnicode_RPartition() */
static PyObject *
unicode_rpartition(PyObject *self, PyObject *args)
{
PyObject *s;
PyObject *sep;

if (!PyArg_ParseTuple(args, "OO", &s, &sep))
return NULL;

NULLABLE(s);
NULLABLE(sep);
return PyUnicode_RPartition(s, sep);
}

/* Test PyUnicode_Translate() */
static PyObject *
unicode_translate(PyObject *self, PyObject *args)
{
PyObject *obj;
PyObject *table;
const char *errors = NULL;

if (!PyArg_ParseTuple(args, "OO|z", &obj, &table, &errors))
return NULL;

NULLABLE(obj);
NULLABLE(table);
return PyUnicode_Translate(obj, table, errors);
}

/* Test PyUnicode_Join() */
static PyObject *
unicode_join(PyObject *self, PyObject *args)
{
PyObject *sep;
PyObject *seq;

if (!PyArg_ParseTuple(args, "OO", &sep, &seq))
return NULL;

NULLABLE(sep);
NULLABLE(seq);
return PyUnicode_Join(sep, seq);
}

/* Test PyUnicode_Count() */
static PyObject *
unicode_count(PyObject *self, PyObject *args)
{
Expand Down Expand Up @@ -938,6 +1061,14 @@ static PyMethodDef TestMethods[] = {
{"unicode_asutf8andsize", unicode_asutf8andsize, METH_VARARGS},
{"unicode_decodeutf8", unicode_decodeutf8, METH_VARARGS},
{"unicode_decodeutf8stateful",unicode_decodeutf8stateful, METH_VARARGS},
{"unicode_concat", unicode_concat, METH_VARARGS},
{"unicode_splitlines", unicode_splitlines, METH_VARARGS},
{"unicode_split", unicode_split, METH_VARARGS},
{"unicode_rsplit", unicode_rsplit, METH_VARARGS},
{"unicode_partition", unicode_partition, METH_VARARGS},
{"unicode_rpartition", unicode_rpartition, METH_VARARGS},
{"unicode_translate", unicode_translate, METH_VARARGS},
{"unicode_join", unicode_join, METH_VARARGS},
{"unicode_count", unicode_count, METH_VARARGS},
{"unicode_tailmatch", unicode_tailmatch, METH_VARARGS},
{"unicode_find", unicode_find, METH_VARARGS},
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.