Skip to content

gh-136823: Update documentation on excluded headers in Python.h #136824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SZeltaat
Copy link
Contributor

@SZeltaat SZeltaat commented Jul 19, 2025

This part of the documentation from https://docs.python.org/3/extending/extending.html#a-simple-example is currently outdated:

All user-visible symbols defined by Python.h have a prefix of Py or PY, except those defined in standard header files. For convenience, and since they are used extensively by the Python interpreter, "Python.h" includes a few standard header files: <stdio.h>, <string.h>, <errno.h>, and <stdlib.h>. If the latter header file does not exist on your system, it declares the functions malloc(), free() and realloc() directly.

This PR aligns the documentation with the code and the comments provided by the original author that implemented the changes.


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

@SZeltaat
Copy link
Contributor Author

Hi @AA-Turner, could you please take a look at this PR?
#EuroPython2025

``PY``, except those defined in standard header files.

Note that :file:`Python.h` excludes ``<stdio.h>``, ``<string.h>``, ``<errno.h>``, and ``<stdlib.h>`` as they are not used by
Python anymore. For backward compatibility of existing third party C extensions, they will
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we write down since which version they are no longer used, as we did for <ctype.h> and <unistd.h>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like the right thing to do, but I couldn't find since which version they are no longer used. @vstinner, you seem to have added that comment to the code 4 years ago. Do you happen to know since which version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked into the different versions. Python 3.10 was indeed the last version of Python that was importing these headers. From Python 3.11 onward, it became conditional.

@ilovelinux, could you please re-review this PR? I believe that with the new changes (as suggested by Sergey), the documentation is now in sync with the actual implementation.

@AA-Turner AA-Turner added sprint needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 19, 2025
@SZeltaat SZeltaat requested a review from ilovelinux July 22, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review 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 sprint
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy