diff options
author | shadchin <shadchin@yandex-team.com> | 2024-12-23 19:39:02 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2024-12-23 19:54:20 +0300 |
commit | 65a5bf9d37a3b29eb394f560b9a09318196c40e8 (patch) | |
tree | e5cd68fb0682b2388e52d9806bb87adc348e21a8 /contrib/tools/python3/Objects/object.c | |
parent | a1dd87a52878ab3e46e5fd2dba5ecbba6113d7e0 (diff) | |
download | ydb-65a5bf9d37a3b29eb394f560b9a09318196c40e8.tar.gz |
Update Python 3 to 3.12.8
commit_hash:c20045b8a987d8720e1f3328270357491d5530f3
Diffstat (limited to 'contrib/tools/python3/Objects/object.c')
-rw-r--r-- | contrib/tools/python3/Objects/object.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/contrib/tools/python3/Objects/object.c b/contrib/tools/python3/Objects/object.c index 6b2e0aeaab..706719116d 100644 --- a/contrib/tools/python3/Objects/object.c +++ b/contrib/tools/python3/Objects/object.c @@ -159,11 +159,27 @@ _PyDebug_PrintTotalRefs(void) { #ifdef Py_TRACE_REFS -#define REFCHAIN(interp) &interp->object_state.refchain +#define REFCHAIN(interp) interp->object_state.refchain + +static inline int +has_own_refchain(PyInterpreterState *interp) +{ + if (interp->feature_flags & Py_RTFLAGS_USE_MAIN_OBMALLOC) { + return (_Py_IsMainInterpreter(interp) + || _PyInterpreterState_Main() == NULL); + } + return 1; +} static inline void init_refchain(PyInterpreterState *interp) { + if (!has_own_refchain(interp)) { + // Legacy subinterpreters share a refchain with the main interpreter. + REFCHAIN(interp) = REFCHAIN(_PyInterpreterState_Main()); + return; + } + REFCHAIN(interp) = &interp->object_state._refchain_obj; PyObject *refchain = REFCHAIN(interp); refchain->_ob_prev = refchain; refchain->_ob_next = refchain; @@ -2010,9 +2026,7 @@ void _PyObject_InitState(PyInterpreterState *interp) { #ifdef Py_TRACE_REFS - if (!_Py_IsMainInterpreter(interp)) { - init_refchain(interp); - } + init_refchain(interp); #endif } |