|
| 1 | +// Entry point of the Python C API. |
| 2 | +// C extensions should only #include <Python.h>, and not include directly |
| 3 | +// the other Python header files included by <Python.h>. |
| 4 | + |
1 | 5 | #ifndef Py_PYTHON_H |
2 | 6 | #define Py_PYTHON_H |
3 | | -/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ |
4 | 7 |
|
5 | | -/* Include nearly all Python header files */ |
| 8 | +// Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { |
6 | 9 |
|
| 10 | +// Include Python header files |
7 | 11 | #include "patchlevel.h" |
8 | 12 | #include "pyconfig.h" |
9 | 13 | #include "pymacconfig.h" |
10 | 14 |
|
11 | | -#include <limits.h> |
12 | | - |
13 | | -#ifndef UCHAR_MAX |
14 | | -#error "Something's broken. UCHAR_MAX should be defined in limits.h." |
15 | | -#endif |
16 | | - |
17 | | -#if UCHAR_MAX != 255 |
18 | | -#error "Python's source code assumes C's unsigned char is an 8-bit type." |
19 | | -#endif |
20 | | - |
21 | 15 | #if defined(__sgi) && !defined(_SGI_MP_SOURCE) |
22 | | -#define _SGI_MP_SOURCE |
| 16 | +# define _SGI_MP_SOURCE |
23 | 17 | #endif |
24 | 18 |
|
25 | | -#include <stdio.h> |
| 19 | +#include <stdio.h> // NULL, FILE* |
26 | 20 | #ifndef NULL |
27 | 21 | # error "Python.h requires that stdio.h define NULL." |
28 | 22 | #endif |
29 | 23 |
|
30 | | -#include <string.h> |
| 24 | +#include <string.h> // memcpy() |
31 | 25 | #ifdef HAVE_ERRNO_H |
32 | | -#include <errno.h> |
| 26 | +# include <errno.h> // errno |
33 | 27 | #endif |
34 | 28 | #include <stdlib.h> |
35 | 29 | #ifndef MS_WINDOWS |
36 | | -#include <unistd.h> |
| 30 | +# include <unistd.h> |
37 | 31 | #endif |
38 | | - |
39 | | -/* For size_t? */ |
40 | 32 | #ifdef HAVE_STDDEF_H |
41 | | -#include <stddef.h> |
| 33 | + // For size_t |
| 34 | +# include <stddef.h> |
42 | 35 | #endif |
43 | 36 |
|
44 | | -/* CAUTION: Build setups should ensure that NDEBUG is defined on the |
45 | | - * compiler command line when building Python in release mode; else |
46 | | - * assert() calls won't be removed. |
47 | | - */ |
48 | 37 | #include <assert.h> |
49 | 38 |
|
50 | 39 | #include "pyport.h" |
51 | 40 | #include "pymacro.h" |
52 | | - |
53 | | -/* A convenient way for code to know if sanitizers are enabled. */ |
54 | | -#if defined(__has_feature) |
55 | | -# if __has_feature(memory_sanitizer) |
56 | | -# if !defined(_Py_MEMORY_SANITIZER) |
57 | | -# define _Py_MEMORY_SANITIZER |
58 | | -# endif |
59 | | -# endif |
60 | | -# if __has_feature(address_sanitizer) |
61 | | -# if !defined(_Py_ADDRESS_SANITIZER) |
62 | | -# define _Py_ADDRESS_SANITIZER |
63 | | -# endif |
64 | | -# endif |
65 | | -#elif defined(__GNUC__) |
66 | | -# if defined(__SANITIZE_ADDRESS__) |
67 | | -# define _Py_ADDRESS_SANITIZER |
68 | | -# endif |
69 | | -#endif |
70 | | - |
71 | 41 | #include "pymath.h" |
72 | 42 | #include "pymem.h" |
73 | | - |
74 | 43 | #include "object.h" |
75 | 44 | #include "objimpl.h" |
76 | 45 | #include "typeslots.h" |
77 | 46 | #include "pyhash.h" |
78 | | - |
79 | 47 | #include "cpython/pydebug.h" |
80 | | - |
81 | 48 | #include "bytearrayobject.h" |
82 | 49 | #include "bytesobject.h" |
83 | 50 | #include "unicodeobject.h" |
|
115 | 82 | #include "namespaceobject.h" |
116 | 83 | #include "cpython/picklebufobject.h" |
117 | 84 | #include "cpython/pytime.h" |
118 | | - |
119 | 85 | #include "codecs.h" |
120 | 86 | #include "pyerrors.h" |
121 | | - |
122 | 87 | #include "cpython/initconfig.h" |
123 | 88 | #include "pythread.h" |
124 | 89 | #include "pystate.h" |
125 | 90 | #include "context.h" |
126 | | - |
127 | 91 | #include "modsupport.h" |
128 | 92 | #include "compile.h" |
129 | 93 | #include "pythonrun.h" |
|
133 | 97 | #include "osmodule.h" |
134 | 98 | #include "intrcheck.h" |
135 | 99 | #include "import.h" |
136 | | - |
137 | 100 | #include "abstract.h" |
138 | 101 | #include "bltinmodule.h" |
139 | | - |
140 | 102 | #include "eval.h" |
141 | | - |
142 | 103 | #include "cpython/pyctype.h" |
143 | 104 | #include "pystrtod.h" |
144 | 105 | #include "pystrcmp.h" |
|
0 commit comments