Skip to content

Commit

Permalink
Python 3.12 support:
Browse files Browse the repository at this point in the history
Change "oldrefcount = 0" to "oldrefcount = self._getRefcounts()" to make sure the ref is counted. This will match python 3.12's change for reference (the original "oldrefcount=0" added 1 ref in 3.11, but does not increase reference count in 3.12).

PiperOrigin-RevId: 731103561
  • Loading branch information
anandolee authored and copybara-github committed Feb 26, 2025
1 parent cb8098d commit 5627e02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/google/protobuf/internal/testing_refleaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def run(self, result=None):
super(ReferenceLeakCheckerMixin, self).run(result=result)
super(ReferenceLeakCheckerMixin, self).run(result=result)

oldrefcount = 0 # pylint: disable=unused-variable but needed for refcounts.
local_result = LocalTestResult(result)
num_flakes = 0

refcount_deltas = []

# Observe the refcount, then create oldrefcount which actually makes the
# refcount 1 higher than the recorded value immediately
oldrefcount = self._getRefcounts()
while len(refcount_deltas) < self.NB_RUNS:
oldrefcount = self._getRefcounts()
super(ReferenceLeakCheckerMixin, self).run(result=local_result)
Expand Down

0 comments on commit 5627e02

Please sign in to comment.