mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-76785: Handle Legacy Interpreters Properly (gh-117490)
This is similar to the situation with threading._DummyThread. The methods (incl. __del__()) of interpreters.Interpreter objects must be careful with interpreters not created by interpreters.create(). The simplest thing to start with is to disable any method that modifies or runs in the interpreter. As part of this, the runtime keeps track of where an interpreter was created. We also handle interpreter "refcounts" properly.
This commit is contained in:
parent
fd2bab9d28
commit
fd259fdabe
9 changed files with 454 additions and 200 deletions
|
@ -109,7 +109,8 @@ struct _is {
|
|||
#define _PyInterpreterState_WHENCE_LEGACY_CAPI 2
|
||||
#define _PyInterpreterState_WHENCE_CAPI 3
|
||||
#define _PyInterpreterState_WHENCE_XI 4
|
||||
#define _PyInterpreterState_WHENCE_MAX 4
|
||||
#define _PyInterpreterState_WHENCE_STDLIB 5
|
||||
#define _PyInterpreterState_WHENCE_MAX 5
|
||||
long _whence;
|
||||
|
||||
/* Has been initialized to a safe state.
|
||||
|
@ -316,6 +317,8 @@ PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *);
|
|||
PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);
|
||||
|
||||
PyAPI_FUNC(int) _PyInterpreterState_IsReady(PyInterpreterState *interp);
|
||||
|
||||
PyAPI_FUNC(long) _PyInterpreterState_GetWhence(PyInterpreterState *interp);
|
||||
extern void _PyInterpreterState_SetWhence(
|
||||
PyInterpreterState *interp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue