diff options
| author | shadchin <[email protected]> | 2025-06-13 00:05:26 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2025-06-13 00:35:30 +0300 |
| commit | 796b9088366b10b4cd42885101fc20c0b5709b07 (patch) | |
| tree | f287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Modules/gcmodule.c | |
| parent | c72bca862651e507d2ff4980ef7f4ff7267a7227 (diff) | |
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Modules/gcmodule.c')
| -rw-r--r-- | contrib/tools/python3/Modules/gcmodule.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/contrib/tools/python3/Modules/gcmodule.c b/contrib/tools/python3/Modules/gcmodule.c index 39856b8eb70..40143bdfb0e 100644 --- a/contrib/tools/python3/Modules/gcmodule.c +++ b/contrib/tools/python3/Modules/gcmodule.c @@ -2445,6 +2445,23 @@ PyObject_GC_IsFinalized(PyObject *obj) return 0; } +static int +visit_generation(gcvisitobjects_t callback, void *arg, struct gc_generation *gen) +{ + PyGC_Head *gc_list, *gc; + gc_list = &gen->head; + for (gc = GC_NEXT(gc_list); gc != gc_list; gc = GC_NEXT(gc)) { + PyObject *op = FROM_GC(gc); + Py_INCREF(op); + int res = callback(op, arg); + Py_DECREF(op); + if (!res) { + return -1; + } + } + return 0; +} + void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg) { @@ -2453,18 +2470,11 @@ PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg) int origenstate = gcstate->enabled; gcstate->enabled = 0; for (i = 0; i < NUM_GENERATIONS; i++) { - PyGC_Head *gc_list, *gc; - gc_list = GEN_HEAD(gcstate, i); - for (gc = GC_NEXT(gc_list); gc != gc_list; gc = GC_NEXT(gc)) { - PyObject *op = FROM_GC(gc); - Py_INCREF(op); - int res = callback(op, arg); - Py_DECREF(op); - if (!res) { - goto done; - } + if (visit_generation(callback, arg, &gcstate->generations[i])) { + goto done; } } + visit_generation(callback, arg, &gcstate->permanent_generation); done: gcstate->enabled = origenstate; } |
