diff options
author | Victor Stinner <vstinner@python.org> | 2024-10-07 21:24:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-07 21:24:53 (GMT) |
commit | a7f0727ca575fef4d8891b5ebfe71ef2a774868b (patch) | |
tree | 1e2f68811bc1485f2d97251ceb8453151d36cc5b /Doc/c-api | |
parent | c5df1cb7bde7e86f046196b0e34a0b90f8fc11de (diff) | |
download | cpython-a7f0727ca575fef4d8891b5ebfe71ef2a774868b.zip cpython-a7f0727ca575fef4d8891b5ebfe71ef2a774868b.tar.gz cpython-a7f0727ca575fef4d8891b5ebfe71ef2a774868b.tar.bz2 |
gh-124502: Add PyUnicode_Equal() function (#124504)
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/unicode.rst | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index b2ac0c9..f5704cf 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1438,6 +1438,31 @@ They all return ``NULL`` or ``-1`` if an exception occurs. This function returns ``-1`` upon failure, so one should call :c:func:`PyErr_Occurred` to check for errors. + .. seealso:: + + The :c:func:`PyUnicode_Equal` function. + + +.. c:function:: int PyUnicode_Equal(PyObject *a, PyObject *b) + + Test if two strings are equal: + + * Return ``1`` if *a* is equal to *b*. + * Return ``0`` if *a* is not equal to *b*. + * Set a :exc:`TypeError` exception and return ``-1`` if *a* or *b* is not a + :class:`str` object. + + The function always succeeds if *a* and *b* are :class:`str` objects. + + The function works for :class:`str` subclasses, but does not honor custom + ``__eq__()`` method. + + .. seealso:: + + The :c:func:`PyUnicode_Compare` function. + + .. versionadded:: 3.14 + .. c:function:: int PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *string, Py_ssize_t size) |