bpo-36611: Fix test_sys.test_getallocatedblocks() (GH-12797) · python/cpython@7182e65 (original) (raw)

Original file line number Diff line number Diff line change
@@ -768,8 +768,13 @@ def test_getallocatedblocks(self):
768 768 except ImportError:
769 769 with_pymalloc = support.with_pymalloc()
770 770 else:
771 -alloc_name = _testcapi.pymem_getallocatorsname()
772 -with_pymalloc = (alloc_name in ('pymalloc', 'pymalloc_debug'))
771 +try:
772 +alloc_name = _testcapi.pymem_getallocatorsname()
773 +except RuntimeError as exc:
774 +# "cannot get allocators name" (ex: tracemalloc is used)
775 +with_pymalloc = True
776 +else:
777 +with_pymalloc = (alloc_name in ('pymalloc', 'pymalloc_debug'))
773 778
774 779 # Some sanity checks
775 780 a = sys.getallocatedblocks()