Debian Codegraph @

pypy/module/cpyext/include/ceval.h

raw symbols SCIP
1 /* Interface to random parts in ceval.c */
2
3 #ifndef Py_CEVAL_H
4 #define Py_CEVAL_H
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
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
17 #ifndef PYPY_VERSION
18 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
19 PyObject *callable,
20 PyObject *args,
21 PyObject *kwargs);
22 #endif
23
24 /* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
25 #define PyEval_CallObject(callable, arg) \
26 PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
27
28 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
29 PyObject *callable, const char *format, ...);
30 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
31 PyObject *obj, const char *name, const char *format, ...);
32
33
34
35 /* Interface for threads.
36
37 A module that plans to do a blocking system call (or something else
38 that lasts a long time and doesn't touch Python data) can allow other
39 threads to run as follows:
40
41 ...preparations here...
42 Py_BEGIN_ALLOW_THREADS
43 ...blocking system call here...
44 Py_END_ALLOW_THREADS
45 ...interpret result here...
46
47 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
48 {}-surrounded block.
49 To leave the block in the middle (e.g., with return), you must insert
50 a line containing Py_BLOCK_THREADS before the return, e.g.
51
52 if (...premature_exit...) {
53 Py_BLOCK_THREADS
54 PyErr_SetFromErrno(PyExc_OSError);
55 return NULL;
56 }
57
58 An alternative is:
59
60 Py_BLOCK_THREADS
61 if (...premature_exit...) {
62 PyErr_SetFromErrno(PyExc_OSError);
63 return NULL;
64 }
65 Py_UNBLOCK_THREADS
66
67 For convenience, that the value of 'errno' is restored across
68 Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
69
70 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
71 Py_END_ALLOW_THREADS!!!
72
73 Note that not yet all candidates have been converted to use this
74 mechanism!
75 */
76
77
78 #define Py_BEGIN_ALLOW_THREADS { \
79 PyThreadState *_save; \
80 _save = PyEval_SaveThread();
81 #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
82 #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
83 #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
84 }
85
86
87 #ifndef PYPY_VERSION
88 PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
89 #endif
90 PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
91
92 #ifdef __cplusplus
93 }
94 #endif
95 #endif /* !Py_CEVAL_H */