mirror of
https://github.com/python/cpython
synced 2026-09-29 11:55:30 +03:00
gh-76785: Add More Tests to test_interpreters.test_api (gh-117662)
In addition to the increase test coverage, this is a precursor to sorting out how we handle interpreters created directly via the C-API.
This commit is contained in:
parent
0cc71bde00
commit
993c3cca16
18 changed files with 2015 additions and 421 deletions
|
|
@ -217,6 +217,11 @@ typedef struct _excinfo {
|
|||
const char *errdisplay;
|
||||
} _PyXI_excinfo;
|
||||
|
||||
PyAPI_FUNC(int) _PyXI_InitExcInfo(_PyXI_excinfo *info, PyObject *exc);
|
||||
PyAPI_FUNC(PyObject *) _PyXI_FormatExcInfo(_PyXI_excinfo *info);
|
||||
PyAPI_FUNC(PyObject *) _PyXI_ExcInfoAsObject(_PyXI_excinfo *info);
|
||||
PyAPI_FUNC(void) _PyXI_ClearExcInfo(_PyXI_excinfo *info);
|
||||
|
||||
|
||||
typedef enum error_code {
|
||||
_PyXI_ERR_NO_ERROR = 0,
|
||||
|
|
@ -313,6 +318,21 @@ PyAPI_FUNC(PyObject *) _PyXI_ApplyCapturedException(_PyXI_session *session);
|
|||
PyAPI_FUNC(int) _PyXI_HasCapturedException(_PyXI_session *session);
|
||||
|
||||
|
||||
/*************/
|
||||
/* other API */
|
||||
/*************/
|
||||
|
||||
// Export for _testinternalcapi shared extension
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyXI_NewInterpreter(
|
||||
PyInterpreterConfig *config,
|
||||
PyThreadState **p_tstate,
|
||||
PyThreadState **p_save_tstate);
|
||||
PyAPI_FUNC(void) _PyXI_EndInterpreter(
|
||||
PyInterpreterState *interp,
|
||||
PyThreadState *tstate,
|
||||
PyThreadState **p_save_tstate);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -103,11 +103,22 @@ struct _is {
|
|||
int requires_idref;
|
||||
PyThread_type_lock id_mutex;
|
||||
|
||||
#define _PyInterpreterState_WHENCE_NOTSET -1
|
||||
#define _PyInterpreterState_WHENCE_UNKNOWN 0
|
||||
#define _PyInterpreterState_WHENCE_RUNTIME 1
|
||||
#define _PyInterpreterState_WHENCE_LEGACY_CAPI 2
|
||||
#define _PyInterpreterState_WHENCE_CAPI 3
|
||||
#define _PyInterpreterState_WHENCE_XI 4
|
||||
#define _PyInterpreterState_WHENCE_MAX 4
|
||||
long _whence;
|
||||
|
||||
/* Has been initialized to a safe state.
|
||||
|
||||
In order to be effective, this must be set to 0 during or right
|
||||
after allocation. */
|
||||
int _initialized;
|
||||
/* Has been fully initialized via pylifecycle.c. */
|
||||
int _ready;
|
||||
int finalizing;
|
||||
|
||||
uintptr_t last_restart_version;
|
||||
|
|
@ -305,6 +316,11 @@ PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *);
|
|||
PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);
|
||||
|
||||
PyAPI_FUNC(long) _PyInterpreterState_GetWhence(PyInterpreterState *interp);
|
||||
extern void _PyInterpreterState_SetWhence(
|
||||
PyInterpreterState *interp,
|
||||
long whence);
|
||||
|
||||
extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
|
||||
|
||||
// Get a copy of the current interpreter configuration.
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ _Py_IsMainInterpreterFinalizing(PyInterpreterState *interp)
|
|||
interp == &_PyRuntime._main_interpreter);
|
||||
}
|
||||
|
||||
// Export for _xxsubinterpreters module.
|
||||
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
|
||||
|
||||
// Export for _xxsubinterpreters module.
|
||||
PyAPI_FUNC(int) _PyInterpreterState_SetRunningMain(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyInterpreterState_SetNotRunningMain(PyInterpreterState *);
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
#define _PyInterpreterState_INIT(INTERP) \
|
||||
{ \
|
||||
.id_refcount = -1, \
|
||||
._whence = _PyInterpreterState_WHENCE_NOTSET, \
|
||||
.imports = IMPORTS_INIT, \
|
||||
.ceval = { \
|
||||
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue