#ifndef Py_PYTHON_H
#define Py_PYTHON_H
-// Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" {
+// Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {"
+// is not needed.
+
// Include Python header files
#include "patchlevel.h"
#include "pyconfig.h"
#include "pymacconfig.h"
-#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
-# define _SGI_MP_SOURCE
+
+// Include standard header files
+#include <assert.h> // assert()
+#include <ctype.h> // tolower()
+#include <inttypes.h> // uintptr_t
+#include <limits.h> // INT_MAX
+#include <stdarg.h> // va_list
+#include <wchar.h> // wchar_t
+#ifdef HAVE_STDDEF_H
+# include <stddef.h> // size_t
+#endif
+#ifndef MS_WINDOWS
+# include <unistd.h> // sysconf()
#endif
-// stdlib.h, stdio.h, errno.h and string.h headers are not used by Python
-// headers, but kept for backward compatibility. They are excluded from the
-// limited C API of Python 3.11.
+// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by Python
+// headers, but kept for backward compatibility (no introduce new compiler
+// warnings). They are not included by the limited C API version 3.11 and
+// above.
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
-# include <stdlib.h>
-# include <stdio.h> // FILE*
# include <errno.h> // errno
+# include <stdio.h> // FILE*
+# include <stdlib.h> // getenv()
# include <string.h> // memcpy()
#endif
-#ifndef MS_WINDOWS
-# include <unistd.h>
-#endif
-#ifdef HAVE_STDDEF_H
-# include <stddef.h> // size_t
-#endif
-#include <assert.h> // assert()
-#include <wchar.h> // wchar_t
+// Include Python header files
#include "pyport.h"
#include "pymacro.h"
#include "pymath.h"
#include "pymem.h"
#include "pytypedefs.h"
#include "pybuffer.h"
+#include "pystats.h"
#include "object.h"
#include "objimpl.h"
#include "typeslots.h"
-
-/* Bytes object interface */
+// Bytes object interface
#ifndef Py_BYTESOBJECT_H
#define Py_BYTESOBJECT_H
extern "C" {
#endif
-#include <stdarg.h> // va_list
-
/*
Type PyBytesObject represents a byte string. An extra zero byte is
reserved at the end to ensure it is zero-terminated, but a size is
# error "this header requires Py_BUILD_CORE define"
#endif
+#ifndef MS_WINDOWS
+# include <unistd.h> // _POSIX_THREADS
+#endif
+
#ifndef _POSIX_THREADS
/* This means pthreads are not implemented in libc headers, hence the macro
not present in unistd.h. But they still can be implemented as an external
+// Module support interface
#ifndef Py_MODSUPPORT_H
#define Py_MODSUPPORT_H
extern "C" {
#endif
-/* Module support interface */
-
-#include <stdarg.h> // va_list
-
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
whose size is determined when the object is allocated.
*/
-#include "pystats.h"
-
/* Py_DEBUG implies Py_REF_DEBUG. */
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
# define Py_REF_DEBUG
-/* The PyObject_ memory family: high-level object memory interfaces.
- See pymem.h for the low-level PyMem_ family.
-*/
+// The PyObject_ memory family: high-level object memory interfaces.
+// See pymem.h for the low-level PyMem_ family.
#ifndef Py_OBJIMPL_H
#define Py_OBJIMPL_H
-
-#include "pymem.h"
-
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
-#endif /* !Py_OBJIMPL_H */
+#endif // !Py_OBJIMPL_H
+// Error handling definitions
+
#ifndef Py_ERRORS_H
#define Py_ERRORS_H
#ifdef __cplusplus
extern "C" {
#endif
-#include <stdarg.h> // va_list
-
-/* Error handling definitions */
-
PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
PyAPI_FUNC(void) PyErr_SetString(
-/* The PyMem_ family: low-level memory allocation interfaces.
- See objimpl.h for the PyObject_ memory family.
-*/
+// The PyMem_ family: low-level memory allocation interfaces.
+// See objimpl.h for the PyObject_ memory family.
#ifndef Py_PYMEM_H
#define Py_PYMEM_H
-
-#include "pyport.h"
-
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
-
-#endif /* !Py_PYMEM_H */
+#endif // !Py_PYMEM_H
#ifndef Py_PYPORT_H
#define Py_PYPORT_H
-#include "pyconfig.h" /* include for defines */
-
-#include <inttypes.h>
-
-#include <limits.h>
#ifndef UCHAR_MAX
-# error "limits.h must define UCHAR_MAX"
+# error "<limits.h> header must define UCHAR_MAX"
#endif
#if UCHAR_MAX != 255
# error "Python's source code assumes C's unsigned char is an 8-bit type"
# define ALIGNOF_MAX_ALIGN_T _Alignof(long double)
#endif
+#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
+# define _SGI_MP_SOURCE
+#endif
+
#endif /* Py_PYPORT_H */
#ifndef Py_UNICODEOBJECT_H
#define Py_UNICODEOBJECT_H
-#include <stdarg.h> // va_list
-
/*
Unicode implementation based on original code by Fredrik Lundh,
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* -------------------------------------------------------------------- */
-#include <ctype.h>
-
/* === Internal API ======================================================= */
/* --- Internal Unicode Format -------------------------------------------- */
# endif
#endif
-#ifdef HAVE_WCHAR_H
-# include <wchar.h>
-#endif
-
/* Py_UCS4 and Py_UCS2 are typedefs for the respective
unicode representations. */
typedef uint32_t Py_UCS4;