File indexing completed on 2025-11-19 09:50:42
0001 #ifndef Py_CPYTHON_PYSTATE_H
0002 # error "this header file must not be included directly"
0003 #endif
0004
0005
0006
0007
0008 PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
0009 PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
0010
0011 PyAPI_FUNC(PyObject *) PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *);
0012
0013
0014
0015
0016 typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
0017
0018
0019
0020
0021
0022
0023 #define PyTrace_CALL 0
0024 #define PyTrace_EXCEPTION 1
0025 #define PyTrace_LINE 2
0026 #define PyTrace_RETURN 3
0027 #define PyTrace_C_CALL 4
0028 #define PyTrace_C_EXCEPTION 5
0029 #define PyTrace_C_RETURN 6
0030 #define PyTrace_OPCODE 7
0031
0032 typedef struct _err_stackitem {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 PyObject *exc_value;
0047
0048 struct _err_stackitem *previous_item;
0049
0050 } _PyErr_StackItem;
0051
0052 typedef struct _stack_chunk {
0053 struct _stack_chunk *previous;
0054 size_t size;
0055 size_t top;
0056 PyObject * data[1];
0057 } _PyStackChunk;
0058
0059 struct _ts {
0060
0061
0062 PyThreadState *prev;
0063 PyThreadState *next;
0064 PyInterpreterState *interp;
0065
0066
0067
0068
0069 uintptr_t eval_breaker;
0070
0071 struct {
0072
0073
0074
0075
0076 unsigned int initialized:1;
0077
0078
0079 unsigned int bound:1;
0080
0081 unsigned int unbound:1;
0082
0083 unsigned int bound_gilstate:1;
0084
0085 unsigned int active:1;
0086
0087 unsigned int holds_gil:1;
0088
0089
0090 unsigned int finalizing:1;
0091 unsigned int cleared:1;
0092 unsigned int finalized:1;
0093
0094
0095 unsigned int :23;
0096 } _status;
0097 #ifdef Py_BUILD_CORE
0098 # define _PyThreadState_WHENCE_NOTSET -1
0099 # define _PyThreadState_WHENCE_UNKNOWN 0
0100 # define _PyThreadState_WHENCE_INIT 1
0101 # define _PyThreadState_WHENCE_FINI 2
0102 # define _PyThreadState_WHENCE_THREADING 3
0103 # define _PyThreadState_WHENCE_GILSTATE 4
0104 # define _PyThreadState_WHENCE_EXEC 5
0105 #endif
0106 int _whence;
0107
0108
0109
0110 int state;
0111
0112 int py_recursion_remaining;
0113 int py_recursion_limit;
0114
0115 int c_recursion_remaining;
0116 int recursion_headroom;
0117
0118
0119
0120
0121 int tracing;
0122 int what_event;
0123
0124
0125 struct _PyInterpreterFrame *current_frame;
0126
0127 Py_tracefunc c_profilefunc;
0128 Py_tracefunc c_tracefunc;
0129 PyObject *c_profileobj;
0130 PyObject *c_traceobj;
0131
0132
0133 PyObject *current_exception;
0134
0135
0136
0137
0138 _PyErr_StackItem *exc_info;
0139
0140 PyObject *dict;
0141
0142 int gilstate_counter;
0143
0144 PyObject *async_exc;
0145 unsigned long thread_id;
0146
0147
0148
0149
0150
0151 unsigned long native_thread_id;
0152
0153 PyObject *delete_later;
0154
0155
0156
0157
0158
0159
0160 uintptr_t critical_section;
0161
0162 int coroutine_origin_tracking_depth;
0163
0164 PyObject *async_gen_firstiter;
0165 PyObject *async_gen_finalizer;
0166
0167 PyObject *context;
0168 uint64_t context_ver;
0169
0170
0171 uint64_t id;
0172
0173 _PyStackChunk *datastack_chunk;
0174 PyObject **datastack_top;
0175 PyObject **datastack_limit;
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190 _PyErr_StackItem exc_state;
0191
0192 PyObject *previous_executor;
0193
0194 uint64_t dict_global_version;
0195
0196
0197 PyObject *threading_local_key;
0198
0199
0200
0201
0202 PyObject *threading_local_sentinel;
0203 };
0204
0205 #ifdef Py_DEBUG
0206
0207
0208 # define Py_C_RECURSION_LIMIT 500
0209 #elif defined(__s390x__)
0210 # define Py_C_RECURSION_LIMIT 800
0211 #elif defined(_WIN32) && defined(_M_ARM64)
0212 # define Py_C_RECURSION_LIMIT 1000
0213 #elif defined(_WIN32)
0214 # define Py_C_RECURSION_LIMIT 3000
0215 #elif defined(__ANDROID__)
0216
0217
0218 # define Py_C_RECURSION_LIMIT 3000
0219 #elif defined(_Py_ADDRESS_SANITIZER)
0220 # define Py_C_RECURSION_LIMIT 4000
0221 #elif defined(__wasi__)
0222
0223 # define Py_C_RECURSION_LIMIT 5000
0224 #else
0225
0226 # define Py_C_RECURSION_LIMIT 10000
0227 #endif
0228
0229
0230
0231
0232
0233
0234 PyAPI_FUNC(PyThreadState *) PyThreadState_GetUnchecked(void);
0235
0236
0237 #define _PyThreadState_UncheckedGet PyThreadState_GetUnchecked
0238
0239
0240
0241 PyAPI_FUNC(void) PyThreadState_EnterTracing(PyThreadState *tstate);
0242
0243
0244
0245 PyAPI_FUNC(void) PyThreadState_LeaveTracing(PyThreadState *tstate);
0246
0247
0248
0249
0250
0251
0252
0253 PyAPI_FUNC(int) PyGILState_Check(void);
0254
0255
0256
0257
0258 PyAPI_FUNC(PyObject*) _PyThread_CurrentFrames(void);
0259
0260
0261
0262 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Main(void);
0263 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
0264 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
0265 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
0266 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
0267 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
0268
0269
0270
0271 typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int);
0272
0273 PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
0274 PyInterpreterState *interp);
0275 PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
0276 PyInterpreterState *interp,
0277 _PyFrameEvalFunction eval_frame);