gh-142083: Document the 'w' type code in the array.array docstring - #158040
Conversation
The type code table in the array.array docstring did not list the 'w' type code, although array.typecodes has included it since 3.13. The other points raised in the issue concerned the 'u' type code, which no longer exists: it was removed, together with its note about narrow and wide builds, in pythongh-80480. What remains is the request to say that 'w' holds Py_UCS4, so the new row names that C type, which is also what the "C Type" column of the table in Doc/library/array.rst gives for 'w'. Add a test asserting that the table lists exactly the supported type codes and that the minimum size it gives for each of them is one the implementation really meets.
|
Applied, thanks. The group holds the bare type code now and the blank line before the assert is there too. One thing worth mentioning, I could not run the test against a fresh build here, the build of this checkout stopped on a missing libatomic unrelated to the patch. I did run it against the stale binary and the regex picked up all fifteen rows of the old table, including Zd and Zf, so the rewrite parses the same thing the previous one did. CI will have a real build. |
|
There is an unrelated failure on GHA Windows: I created #158574 to track this test_external_inspection failure. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
@v0ropaev: It seems like you used a LLM to create this PR and writes its description. LLM are too verbose. Next time, try at least to write the PR description with your own words. There is no need to elaborate that much just to add "w" to a docstring.
|
Sorry, @v0ropaev and @vstinner, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @v0ropaev and @vstinner, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-158575 is a backport of this pull request to the 3.15 branch. |
|
I'd like to join Victor as I share his sentiment in that too many tokens to consume make for a lot of cognitive burden for the reviewers of which there are too few. |
The type-code table in
array.array.__doc__is missing'w':help(array.array)therefore lists fifteen type codes where the module supports sixteen, and'w'is the one a reader is most likely to be looking for, since it replaced the removed'u'.The issue also mentioned the narrow/wide-build note. That half is already done: 46b5e3e ("gh-80480: Remove deprecated 'u' array type code") deleted both the
'u'row and the note along with it.'w'is what is left.Change
One line in the docstring, placed after
'B'so the order matchesdescriptors[]and the table inDoc/library/array.rst. TheC Typecolumn saysPy_UCS4, which is what the rst table's C-type column says for this row — if you would rather it readUnicode character(the rst's Python type column) or something looser like the neighbouringsigned integerrows, say so and I will change it; that is the only judgment call in the diff.The previous attempt at this, #142323, was closed after @vstinner wrote "Your PR doesn't build successfully. Your change is not correct." That diff spliced
"...\n"quoted lines into the middle of the backslash-continuedPyDoc_STRVARliteral, which cannot compile. This one keeps the\n\continuation that every other row uses, and builds:Test
Rather than assert the one new row,
test_typecodes_documentedparses the whole table out of the docstring and asserts two things: that it lists exactlyarray.typecodes, and that each documented minimum size is one the implementation actually meets. So the next type code added or removed cannot silently desync the docstring again, which is how'w'came to be missing in the first place.It is guarded with
@support.cpython_onlyand@support.requires_docstrings, so it skips under-OOand on implementations without docstrings:Delete-the-fix check, run by removing the added line and rebuilding:
array.typecodesis built unconditionally fromdescriptors[]at module init, so the set comparison does not depend on the platform havinglong long.News entry in
Misc/NEWS.d/next/Documentation/— the docstring is user-visible throughhelp().