Skip to content

Conversation

@Yashp002
Copy link
Contributor

@Yashp002 Yashp002 commented Jan 6, 2026

This PR documents PyUnicode_IS_COMPACT and PyUnicode_IS_COMPACT_ASCII, which were identified as undocumented public macros in issue #141004.


📚 Documentation preview 📚: https://cpython-previews--143494.org.readthedocs.build/

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Jan 6, 2026
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Jan 6, 2026
.. c:macro:: PyUnicode_IS_COMPACT(o)
Return true if the Unicode object *o* is a compact string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a small definition of what a "compact" string is? Same goes for IS_COMPACT_ASCII below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, coming right up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather say they use the PyCompactUnicodeObject struct (and PyASCIIObject for COMPACT_ASCII). The docs for the structs discourage using them directly, which is a good thing. I don't think we should provide any details on the storage layouts.

Ideally, document these together with the struct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also move the docs to the structs they refer to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also move the docs to the structs they refer to?

I've moved them, please verify if its satisfactory placement. it groups the "Type" and "How to check for that Type" logic imo.

@encukou
Copy link
Member

encukou commented Jan 7, 2026

(FWIW, I want to deprecate these, but they have a use case that'll need a PEP with better API: https://discuss.python.org/t/82543.) [edit: link fixed)

@encukou
Copy link
Member

encukou commented Jan 7, 2026

Could you also remove these from Tools/check-c-api-docs/ignored_c_api.txt?

@Yashp002
Copy link
Contributor Author

Yashp002 commented Jan 7, 2026

I'll update the wording.

And yes, I'll remove them from ignored_c_api.txt to ensure they are properly checked going forward.
also the link u've sent is a "Page not found".

PyUnstable_EXECUTABLE_KIND_SKIP
# cpython/pylifecycle.h
Py_FrozenMain
# cpython/unicodeobject.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment as well.

Yashp002 and others added 2 commits January 8, 2026 22:28
@Yashp002
Copy link
Contributor Author

Yashp002 commented Jan 8, 2026

Test failure unrelated to my docs change - multiprocessing timeout issue.
@ZeroIntensity , @encukou

@ZeroIntensity
Copy link
Member

ZeroIntensity commented Jan 9, 2026

ignored_c_api.txt has some conflicts now.

@Yashp002
Copy link
Contributor Author

Yashp002 commented Jan 9, 2026

ignored_c_api.txt has some conflicts now.

Wait I'm sorry, do we go with the incoming change or the current change here?
@ZeroIntensity

@ZeroIntensity
Copy link
Member

We needed to merge the two. I fixed it for you.

@Yashp002
Copy link
Contributor Author

Yashp002 commented Jan 9, 2026

@ZeroIntensity Yeah my bad, i was a little confused there. Thanks for the help

Edit: I also think we need to remove some more lines from the ignore_c_api.txt as it claims some things to be documented but still existing in the file.

@Yashp002
Copy link
Contributor Author

@ZeroIntensity Could you update me on this PR?
It still seems to be failing one test after the ignorecapi.txt fix

@ZeroIntensity
Copy link
Member

It's complaining that some C APIs are documented but also listed in ignored_c_api.txt. Just remove those.

@Yashp002
Copy link
Contributor Author

@ZeroIntensity I think i fixed the test problem yeah

@encukou encukou merged commit 42f7c2d into python:main Jan 12, 2026
59 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jan 12, 2026
@miss-islington-app
Copy link

Thanks @Yashp002 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @Yashp002 and @encukou, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 42f7c2dfba58a8a8f31aba727d0fc51dd3ce2fce 3.14

@miss-islington-app
Copy link

Sorry, @Yashp002 and @encukou, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 42f7c2dfba58a8a8f31aba727d0fc51dd3ce2fce 3.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants