From e18f5a6d2696c031d34cf4933dcdd6a8e37f6f85 Mon Sep 17 00:00:00 2001 From: Yurii Date: Wed, 19 Aug 2026 10:39:42 +0300 Subject: [PATCH] Simplify GCDisabledGuard constructor Combine PyGC_IsEnabled and PyGC_Disable into PyGC_Disable as it already returns previous state of garbage collector. --- src/greenlet/TGreenlet.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/greenlet/TGreenlet.hpp b/src/greenlet/TGreenlet.hpp index 7838ab92..d726a615 100644 --- a/src/greenlet/TGreenlet.hpp +++ b/src/greenlet/TGreenlet.hpp @@ -828,10 +828,8 @@ class TracingGuard int was_enabled = 0; public: GCDisabledGuard() - : was_enabled(PyGC_IsEnabled()) - { - PyGC_Disable(); - } + : was_enabled(PyGC_Disable()) + {} ~GCDisabledGuard() {