Skip to content

Commit a527aaf

Browse files
committed
Fix immortality test
1 parent 0bae25d commit a527aaf

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Lib/test/test_builtin.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,18 +2694,15 @@ def __del__(self):
26942694
class ImmortalTests(unittest.TestCase):
26952695

26962696
if sys.maxsize < (1 << 32):
2697-
if support.Py_GIL_DISABLED:
2698-
IMMORTAL_REFCOUNT = 5 << 28
2699-
else:
2700-
IMMORTAL_REFCOUNT = 7 << 28
2697+
IMMORTAL_REFCOUNT_MINIMUM = 1 << 30
27012698
else:
2702-
IMMORTAL_REFCOUNT = 3 << 30
2699+
IMMORTAL_REFCOUNT_MINIMUM = 1 << 31
27032700

27042701
IMMORTALS = (None, True, False, Ellipsis, NotImplemented, *range(-5, 257))
27052702

27062703
def assert_immortal(self, immortal):
27072704
with self.subTest(immortal):
2708-
self.assertEqual(sys.getrefcount(immortal), self.IMMORTAL_REFCOUNT)
2705+
self.assertGreater(sys.getrefcount(immortal), self.IMMORTAL_REFCOUNT_MINIMUM)
27092706

27102707
def test_immortals(self):
27112708
for immortal in self.IMMORTALS:

Python/sysmodule.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,6 @@ static Py_ssize_t
19541954
sys_getrefcount_impl(PyObject *module, PyObject *object)
19551955
/*[clinic end generated code: output=5fd477f2264b85b2 input=bf474efd50a21535]*/
19561956
{
1957-
if (_Py_IsImmortal(object)) {
1958-
return _Py_IMMORTAL_INITIAL_REFCNT;
1959-
}
19601957
return Py_REFCNT(object);
19611958
}
19621959

0 commit comments

Comments
 (0)