This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyUnicode_Tailmatch documentation does not match signature
Type: Stage: resolved
Components: Unicode Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Josh.Ayers, ezio.melotti, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2014-10-08 15:11 by Josh.Ayers, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg228797 - (view) Author: Josh Ayers (Josh.Ayers) Date: 2014-10-08 15:11
The documentation for PyUnicode_Tailmatch says it returns an int:
https://docs.python.org/3/c-api/unicode.html?highlight=pyunicode_tailmatch#c.PyUnicode_Tailmatch


However, the include file shows it returns Py_ssize_t:
https://hg.python.org/cpython/file/f21f0de30544/Include/unicodeobject.h#l1952
msg228843 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-09 09:12
New changeset 4aba14bb6b1e by Victor Stinner in branch '3.4':
Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/4aba14bb6b1e

New changeset 335d16d864e1 by Victor Stinner in branch 'default':
(Merge 3.4) Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/335d16d864e1
msg228844 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-09 09:14
New changeset de4ffe244440 by Victor Stinner in branch '2.7':
Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/de4ffe244440
msg228845 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-09 09:14
> The documentation for PyUnicode_Tailmatch says it returns an int

It's an old bug (since Python 2.7 or older) and it is now fixed. Thanks for the report Josh.
msg228955 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-10-10 06:47
It looks rather as a bug in C code. There is no need to return Py_ssize_t instead of int.
msg228960 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-10 07:36
> It looks rather as a bug in C code. There is no need to return Py_ssize_t instead of int.

Oh yes, you're right. A Py_ssize_t to return -1, 0 or 1 is overkill :-)

But PyUnicode_Tailmatch() is now part of the stable ABI, the inefficient return type is not a bug import enough to break the ABI in Python 3.5.

In Python 2.7, I see for example that the function is implemented with tailmatch() which returns an int, and PyUnicode_Tailmatch() casts it to Py_ssize_t.
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66770
2014-10-10 07:36:19vstinnersetmessages: + msg228960
2014-10-10 06:47:51serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg228955
2014-10-09 09:14:46vstinnersetmessages: + msg228845
2014-10-09 09:14:13python-devsetmessages: + msg228844
2014-10-09 09:12:01python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg228843

resolution: fixed
stage: resolved
2014-10-08 15:11:59Josh.Ayerscreate