From d511f2a22bf0c07a247a3db2b9dc8324b48a6bb2 Mon Sep 17 00:00:00 2001 From: Martin DeMello Date: Wed, 26 Mar 2025 18:53:21 -0700 Subject: [PATCH] Minor readability fix in PyUnstable_GC_VisitObjects Replaces `if (visit_generation())` with `if (visit_generation() < 0)`, since we are checking for the failure case, and it's confusing to have that be implicitly `true`. Also fixes a misspelt variable name. --- Python/gc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/gc.c b/Python/gc.c index 8d7f6ac2f3ab53..e37d4b76456acc 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -2407,20 +2407,20 @@ void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg) { GCState *gcstate = get_gc_state(); - int origenstate = gcstate->enabled; + int original_state = gcstate->enabled; gcstate->enabled = 0; - if (visit_generation(callback, arg, &gcstate->young)) { + if (visit_generation(callback, arg, &gcstate->young) < 0) { goto done; } - if (visit_generation(callback, arg, &gcstate->old[0])) { + if (visit_generation(callback, arg, &gcstate->old[0]) < 0) { goto done; } - if (visit_generation(callback, arg, &gcstate->old[1])) { + if (visit_generation(callback, arg, &gcstate->old[1]) < 0) { goto done; } visit_generation(callback, arg, &gcstate->permanent_generation); done: - gcstate->enabled = origenstate; + gcstate->enabled = original_state; } #endif // Py_GIL_DISABLED