]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130125)
authorStan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Mon, 17 Feb 2025 13:07:59 +0000 (13:07 +0000)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2025 13:07:59 +0000 (14:07 +0100)
commit8a598fb6237a0e572d0e7ce55555ef26b903b657
treedeb8c44e28237b5605265db6614c7e382d133656
parentfc1c35f44d7309a42578e4d9c98670b244803d32
[3.12] gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130125)

We had the definition of what makes a character "printable" documented in three places, giving two different definitions.
The definition in the comment on `_PyUnicode_IsPrintable` was inverted; correct that.

With that correction, the two definitions turn out to be equivalent -- but to confirm that, you have to go look up, or happen to know, that those are the only five "Other" categories and only three "Separator" categories in the Unicode character database.  That makes it hard for the reader to tell whether they really are the same, or if there's some subtle difference in the intended semantics.

Fix that by cutting the C API docs' and the C comment's copies of the subtle details, in favor of referring to the Python-level docs. That ensures it's explicit that these are all meant to agree, and also lets us concentrate improvements to the wording in one place.

Speaking of which, borrow some ideas from the C comment, along with other tweaks, to hopefully add a bit more clarity to that one newly-centralized copy in the docs.

Also add a thorough test that the implementation agrees with this definition.

Co-authored-by: Greg Price <gnprice@gmail.com>
(cherry picked from commit 3402e133ef26736296c07992266a82b181a5d532)
Doc/c-api/unicode.rst
Doc/library/stdtypes.rst
Lib/test/test_unicode.py
Objects/clinic/unicodeobject.c.h
Objects/unicodectype.c
Objects/unicodeobject.c