mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-76785: Improved Subinterpreters Compatibility with 3.12 (2/2) (gh-126707)
These changes makes it easier to backport the _interpreters, _interpqueues, and _interpchannels modules to Python 3.12. This involves the following: * add the _PyXI_GET_STATE() and _PyXI_GET_GLOBAL_STATE() macros * add _PyXIData_lookup_context_t and _PyXIData_GetLookupContext() * add _Py_xi_state_init() and _Py_xi_state_fini()
This commit is contained in:
parent
6b2a19681e
commit
73cf069099
9 changed files with 248 additions and 92 deletions
|
@ -8,15 +8,24 @@
|
|||
static int
|
||||
ensure_xid_class(PyTypeObject *cls, xidatafunc getdata)
|
||||
{
|
||||
//assert(cls->tp_flags & Py_TPFLAGS_HEAPTYPE);
|
||||
return _PyXIData_RegisterClass(cls, getdata);
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
_PyXIData_lookup_context_t ctx;
|
||||
if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return _PyXIData_RegisterClass(&ctx, cls, getdata);
|
||||
}
|
||||
|
||||
#ifdef REGISTERS_HEAP_TYPES
|
||||
static int
|
||||
clear_xid_class(PyTypeObject *cls)
|
||||
{
|
||||
return _PyXIData_UnregisterClass(cls);
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
_PyXIData_lookup_context_t ctx;
|
||||
if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return _PyXIData_UnregisterClass(&ctx, cls);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue