Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ceval.h146 linesDownload Raw Back to include
1/* Interface to random parts in ceval.c */2 3#ifndef Py_CEVAL_H4#define Py_CEVAL_H5#ifdef __cplusplus6extern "C" {7#endif8 9 10PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);11 12PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,13                                         PyObject *globals,14                                         PyObject *locals,15                                         PyObject *const *args, int argc,16                                         PyObject *const *kwds, int kwdc,17                                         PyObject *const *defs, int defc,18                                         PyObject *kwdefs, PyObject *closure);19 20PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);21PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);22PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);23PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void);24 25PyAPI_FUNC(PyObject *) PyEval_GetFrameBuiltins(void);26PyAPI_FUNC(PyObject *) PyEval_GetFrameGlobals(void);27PyAPI_FUNC(PyObject *) PyEval_GetFrameLocals(void);28 29PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);30PyAPI_FUNC(int) Py_MakePendingCalls(void);31 32/* Protection against deeply nested recursive calls33 34   In Python 3.0, this protection has two levels:35   * normal anti-recursion protection is triggered when the recursion level36     exceeds the current recursion limit. It raises a RecursionError, and sets37     the "overflowed" flag in the thread state structure. This flag38     temporarily *disables* the normal protection; this allows cleanup code39     to potentially outgrow the recursion limit while processing the40     RecursionError.41   * "last chance" anti-recursion protection is triggered when the recursion42     level exceeds "current recursion limit + 50". By construction, this43     protection can only be triggered when the "overflowed" flag is set. It44     means the cleanup code has itself gone into an infinite loop, or the45     RecursionError has been mistakenly ignored. When this protection is46     triggered, the interpreter aborts with a Fatal Error.47 48   In addition, the "overflowed" flag is automatically reset when the49   recursion level drops below "current recursion limit - 50". This heuristic50   is meant to ensure that the normal anti-recursion protection doesn't get51   disabled too long.52 53   Please note: this scheme has its own limitations. See:54   http://mail.python.org/pipermail/python-dev/2008-August/082106.html55   for some observations.56*/57PyAPI_FUNC(void) Py_SetRecursionLimit(int);58PyAPI_FUNC(int) Py_GetRecursionLimit(void);59 60PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);61PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);62 63PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);64PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);65 66PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *);67PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);68 69/* Interface for threads.70 71   A module that plans to do a blocking system call (or something else72   that lasts a long time and doesn't touch Python data) can allow other73   threads to run as follows:74 75    ...preparations here...76    Py_BEGIN_ALLOW_THREADS77    ...blocking system call here...78    Py_END_ALLOW_THREADS79    ...interpret result here...80 81   The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a82   {}-surrounded block.83   To leave the block in the middle (e.g., with return), you must insert84   a line containing Py_BLOCK_THREADS before the return, e.g.85 86    if (...premature_exit...) {87        Py_BLOCK_THREADS88        PyErr_SetFromErrno(PyExc_OSError);89        return NULL;90    }91 92   An alternative is:93 94    Py_BLOCK_THREADS95    if (...premature_exit...) {96        PyErr_SetFromErrno(PyExc_OSError);97        return NULL;98    }99    Py_UNBLOCK_THREADS100 101   For convenience, that the value of 'errno' is restored across102   Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.103 104   WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND105   Py_END_ALLOW_THREADS!!!106 107   Note that not yet all candidates have been converted to use this108   mechanism!109*/110 111PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);112PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);113 114Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);115 116PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);117PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);118 119#define Py_BEGIN_ALLOW_THREADS { \120                        PyThreadState *_save; \121                        _save = PyEval_SaveThread();122#define Py_BLOCK_THREADS        PyEval_RestoreThread(_save);123#define Py_UNBLOCK_THREADS      _save = PyEval_SaveThread();124#define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \125                 }126 127/* Masks and values used by FORMAT_VALUE opcode. */128#define FVC_MASK      0x3129#define FVC_NONE      0x0130#define FVC_STR       0x1131#define FVC_REPR      0x2132#define FVC_ASCII     0x3133#define FVS_MASK      0x4134#define FVS_HAVE_SPEC 0x4135 136#ifndef Py_LIMITED_API137#  define Py_CPYTHON_CEVAL_H138#  include "cpython/ceval.h"139#  undef Py_CPYTHON_CEVAL_H140#endif141 142#ifdef __cplusplus143}144#endif145#endif /* !Py_CEVAL_H */146 
codekingpro/portable-devtools · Team Ai