https://github.com/python/cpython/commit/9c1e85fd64cf6a85f7c96390d7b2dfad03a76944
commit: 9c1e85fd64cf6a85f7c96390d7b2dfad03a76944
branch: main
author: Martin DeMello <[email protected]>
committer: corona10 <[email protected]>
date: 2025-03-29T08:58:17+09:00
summary:
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.
files:
M Python/gc.c
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
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]