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 | |
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')
-rw-r--r-- | Doc/c-api/unicode.rst | 25 | ||||
-rw-r--r-- | Doc/data/stable_abi.dat | 1 | ||||
-rw-r--r-- | Doc/whatsnew/3.14.rst | 4 |
3 files changed, 30 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) diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat index 19dc71a..9314fac 100644 --- a/Doc/data/stable_abi.dat +++ b/Doc/data/stable_abi.dat @@ -783,6 +783,7 @@ func,PyUnicode_DecodeUnicodeEscape,3.2,, func,PyUnicode_EncodeCodePage,3.7,on Windows, func,PyUnicode_EncodeFSDefault,3.2,, func,PyUnicode_EncodeLocale,3.7,, +func,PyUnicode_Equal,3.14,, func,PyUnicode_EqualToUTF8,3.13,, func,PyUnicode_EqualToUTF8AndSize,3.13,, func,PyUnicode_FSConverter,3.2,, diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 67d8d38..f1f78ed 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -687,6 +687,10 @@ New Features <https://peps.python.org/pep-0630/#type-checking>`__ mentioned in :pep:`630` (:gh:`124153`). +* Add :c:func:`PyUnicode_Equal` function to the limited C API: + test if two strings are equal. + (Contributed by Victor Stinner in :gh:`124502`.) + Porting to Python 3.14 ---------------------- |