Skip to content

Commit 9c1e85f

Browse files
gh-131740: minor readability fix in PyUnstable_GC_VisitObjects (gh-131786)
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.
1 parent 2984ff9 commit 9c1e85f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Python/gc.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2407,20 +2407,20 @@ void
24072407
PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
24082408
{
24092409
GCState *gcstate = get_gc_state();
2410-
int origenstate = gcstate->enabled;
2410+
int original_state = gcstate->enabled;
24112411
gcstate->enabled = 0;
2412-
if (visit_generation(callback, arg, &gcstate->young)) {
2412+
if (visit_generation(callback, arg, &gcstate->young) < 0) {
24132413
goto done;
24142414
}
2415-
if (visit_generation(callback, arg, &gcstate->old[0])) {
2415+
if (visit_generation(callback, arg, &gcstate->old[0]) < 0) {
24162416
goto done;
24172417
}
2418-
if (visit_generation(callback, arg, &gcstate->old[1])) {
2418+
if (visit_generation(callback, arg, &gcstate->old[1]) < 0) {
24192419
goto done;
24202420
}
24212421
visit_generation(callback, arg, &gcstate->permanent_generation);
24222422
done:
2423-
gcstate->enabled = origenstate;
2423+
gcstate->enabled = original_state;
24242424
}
24252425

24262426
#endif // Py_GIL_DISABLED

0 commit comments

Comments
 (0)