Skip to content

Commit d9503af

Browse files
committed
[Python] Update expected refcounts for Python 3.14 in Numba tests
Similar to f26668d and 6c3a574. Also, fix a wrong version comparison in the Python comments. (cherry picked from commit 2429af9)
1 parent 4224d9a commit d9503af

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

bindings/pyroot/pythonizations/test/numbadeclare.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ class NumbaDeclareSimple(unittest.TestCase):
2121
def test_refcount_decorator(self):
2222
"""
2323
Test refcount of decorator
24+
25+
In case of Python < 3.14, we expect a refcount of 2, because the call
26+
to sys.getrefcount can create an additional reference itself. Starting
27+
from Python 3.14, we expect a refcount of 1 because there were changes
28+
to the interpreter to avoid some unnecessary ref counts. See also:
29+
https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-refcount
2430
"""
2531
x = ROOT.Numba.Declare(["float"], "float")
2632
gc.collect()
27-
self.assertEqual(sys.getrefcount(x), 2)
33+
extra_ref_count = int(sys.version_info < (3, 14))
34+
self.assertEqual(sys.getrefcount(x), 1 + extra_ref_count)
2835

2936
def test_refcount_pycallable(self):
3037
"""

bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_refcount(self):
7676
"""
7777
Check refcounts of associated PyObjects
7878
79-
In case of Python <=3.14, we expect a refcount of 2 for the data dict,
79+
In case of Python < 3.14, we expect a refcount of 2 for the data dict,
8080
because the call to sys.getrefcount creates a second reference by
8181
itself. Starting from Python 3.14, we expect a refcount of 1 because
8282
there were changes to the interpreter to avoid some unnecessary ref

bindings/pyroot/pythonizations/test/rvec_asrvec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_refcount(self):
123123
"""
124124
Test reference count of returned RVec
125125
126-
In case of Python <=3.14, we expect a refcount of 2 for the RVec
126+
In case of Python < 3.14, we expect a refcount of 2 for the RVec
127127
because the call to sys.getrefcount creates a second reference by
128128
itself. Starting from Python 3.14, we expect a refcount of 1 because
129129
there were changes to the interpreter to avoid some unnecessary ref

0 commit comments

Comments
 (0)