1#ifndef Py_CEVAL_H
2#define Py_CEVAL_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7
8/* Interface to random parts in ceval.c */
9
10/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
11 * and PyEval_CallMethod are deprecated. Since they are officially part of the
12 * stable ABI (PEP 384), they must be kept for backward compatibility.
13 * PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
14 * recommended to call a callable object.
15 */
16
17Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
18 PyObject *callable,
19 PyObject *args,
20 PyObject *kwargs);
21
22/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
23#define PyEval_CallObject(callable, arg) \
24 PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
25
26Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
27 PyObject *callable, const char *format, ...);
28Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
29 PyObject *obj, const char *name, const char *format, ...);
30
31PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
32PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
33PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
34PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void);
35
36PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
37PyAPI_FUNC(int) Py_MakePendingCalls(void);
38
39/* Protection against deeply nested recursive calls
40
41 In Python 3.0, this protection has two levels:
42 * normal anti-recursion protection is triggered when the recursion level
43 exceeds the current recursion limit. It raises a RecursionError, and sets
44 the "overflowed" flag in the thread state structure. This flag
45 temporarily *disables* the normal protection; this allows cleanup code
46 to potentially outgrow the recursion limit while processing the
47 RecursionError.
48 * "last chance" anti-recursion protection is triggered when the recursion
49 level exceeds "current recursion limit + 50". By construction, this
50 protection can only be triggered when the "overflowed" flag is set. It
51 means the cleanup code has itself gone into an infinite loop, or the
52 RecursionError has been mistakingly ignored. When this protection is
53 triggered, the interpreter aborts with a Fatal Error.
54
55 In addition, the "overflowed" flag is automatically reset when the
56 recursion level drops below "current recursion limit - 50". This heuristic
57 is meant to ensure that the normal anti-recursion protection doesn't get
58 disabled too long.
59
60 Please note: this scheme has its own limitations. See:
61 http://mail.python.org/pipermail/python-dev/2008-August/082106.html
62 for some observations.
63*/
64PyAPI_FUNC(void) Py_SetRecursionLimit(int);
65PyAPI_FUNC(int) Py_GetRecursionLimit(void);
66
67PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
68PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);
69
70PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
71PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
72
73PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *);
74PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);
75
76/* Interface for threads.
77
78 A module that plans to do a blocking system call (or something else
79 that lasts a long time and doesn't touch Python data) can allow other
80 threads to run as follows:
81
82 ...preparations here...
83 Py_BEGIN_ALLOW_THREADS
84 ...blocking system call here...
85 Py_END_ALLOW_THREADS
86 ...interpret result here...
87
88 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
89 {}-surrounded block.
90 To leave the block in the middle (e.g., with return), you must insert
91 a line containing Py_BLOCK_THREADS before the return, e.g.
92
93 if (...premature_exit...) {
94 Py_BLOCK_THREADS
95 PyErr_SetFromErrno(PyExc_OSError);
96 return NULL;
97 }
98
99 An alternative is:
100
101 Py_BLOCK_THREADS
102 if (...premature_exit...) {
103 PyErr_SetFromErrno(PyExc_OSError);
104 return NULL;
105 }
106 Py_UNBLOCK_THREADS
107
108 For convenience, that the value of 'errno' is restored across
109 Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
110
111 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
112 Py_END_ALLOW_THREADS!!!
113
114 Note that not yet all candidates have been converted to use this
115 mechanism!
116*/
117
118PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
119PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
120
121Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
122Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
123/* PyEval_AcquireLock() and PyEval_ReleaseLock() are part of stable ABI.
124 * They will be removed from this header file in the future version.
125 * But they will be remained in ABI until Python 4.0.
126 */
127Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
128Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_ReleaseLock(void);
129PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
130PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
131
132#define Py_BEGIN_ALLOW_THREADS { \
133 PyThreadState *_save; \
134 _save = PyEval_SaveThread();
135#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
136#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
137#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
138 }
139
140/* Masks and values used by FORMAT_VALUE opcode. */
141#define FVC_MASK 0x3
142#define FVC_NONE 0x0
143#define FVC_STR 0x1
144#define FVC_REPR 0x2
145#define FVC_ASCII 0x3
146#define FVS_MASK 0x4
147#define FVS_HAVE_SPEC 0x4
148
149#ifndef Py_LIMITED_API
150# define Py_CPYTHON_CEVAL_H
151# include "cpython/ceval.h"
152# undef Py_CPYTHON_CEVAL_H
153#endif
154
155#ifdef __cplusplus
156}
157#endif
158#endif /* !Py_CEVAL_H */
159

source code of include/python3.10/ceval.h