gh-124502: Add PyUnicode_Equal() function (#124504)

This commit is contained in:
Victor Stinner 2024-10-07 23:24:53 +02:00 committed by GitHub
parent c5df1cb7bd
commit a7f0727ca5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 111 additions and 2 deletions

View file

@ -1,7 +1,7 @@
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
// Need limited C API 3.13 to test PyUnicode_EqualToUTF8()
# define Py_LIMITED_API 0x030d0000
// Need limited C API 3.14 to test PyUnicode_Equal()
# define Py_LIMITED_API 0x030e0000
#endif
#include "parts.h"
@ -1837,6 +1837,23 @@ test_string_from_format(PyObject *self, PyObject *Py_UNUSED(ignored))
#undef CHECK_FORMAT_0
}
/* Test PyUnicode_Equal() */
static PyObject *
unicode_equal(PyObject *module, PyObject *args)
{
PyObject *str1, *str2;
if (!PyArg_ParseTuple(args, "OO", &str1, &str2)) {
return NULL;
}
NULLABLE(str1);
NULLABLE(str2);
RETURN_INT(PyUnicode_Equal(str1, str2));
}
static PyMethodDef TestMethods[] = {
{"codec_incrementalencoder", codec_incrementalencoder, METH_VARARGS},
{"codec_incrementaldecoder", codec_incrementaldecoder, METH_VARARGS},
@ -1924,6 +1941,7 @@ static PyMethodDef TestMethods[] = {
{"unicode_format", unicode_format, METH_VARARGS},
{"unicode_contains", unicode_contains, METH_VARARGS},
{"unicode_isidentifier", unicode_isidentifier, METH_O},
{"unicode_equal", unicode_equal, METH_VARARGS},
{NULL},
};