Skip to content

Commit 7e3b66f

Browse files
committed
apply suggestions from code review
1 parent cefc8f9 commit 7e3b66f

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Doc/extending/extending.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,33 @@ the module and a copyright notice if you like).
7777
All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` or
7878
``PY``, except those defined in standard header files.
7979

80-
For backward compatibility, :file:`!Python.h`
81-
includes ``<stdio.h>``, ``<string.h>``, ``<errno.h>``, and ``<stdlib.h>`` if
82-
:c:macro:`Py_LIMITED_API` is not defined or for limited C API version 3.10 and older.
83-
The ``<ctype.h>`` and ``<unistd.h>`` headers are also not included for limited
84-
C API version 3.13 and newer.
85-
80+
For backward compatibility, :file:`Python.h` includes several standard header files.
81+
C extensions should include the standard headers that they use, and should not rely
82+
on these implicit includes.
83+
If using the limited C API version 3.13 or newer, the implicit includes are:
84+
85+
* ``<assert.h>``
86+
* ``<intrin.h>`` (on Windows)
87+
* ``<inttypes.h>``
88+
* ``<limits.h>``
89+
* ``<math.h>``
90+
* ``<stdarg.h>``
91+
* ``<wchar.h>``
92+
* ``<sys/types.h>`` (if present)
93+
94+
If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.12 or older,
95+
the headers below are also included:
96+
97+
* ``<ctype.h>``
98+
* ``<unistd.h>`` (on POSIX)
99+
100+
If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.10 or older,
101+
the headers below are also included:
102+
103+
* ``<errno.h>``
104+
* ``<stdio.h>``
105+
* ``<stdlib.h>``
106+
* ``<string.h>``
86107

87108
The next thing we add to our module file is the C function that will be called
88109
when the Python expression ``spam.system(string)`` is evaluated (we'll see

Include/Python.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// C extensions should only #include <Python.h>, and not include directly
33
// the other Python header files included by <Python.h>.
44

5+
// Note: If the included standard headers change, please update the documentation
6+
// (including the documentation for C extensions) accordingly.
7+
8+
59
#ifndef Py_PYTHON_H
610
#define Py_PYTHON_H
711

0 commit comments

Comments
 (0)