mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-36611: Fix test_sys.test_getallocatedblocks() (GH-12797)
Fix test_sys.test_getallocatedblocks() when tracemalloc is enabled. If the name of Python memory allocators cannot get read, consider that pymalloc is disabled. Fix the following error: ./python -X tracemalloc -m test test_sys -v -m test_getallocatedblocks ERROR: test_getallocatedblocks (test.test_sys.SysModuleTest) ------------------------------------------------------------ Traceback (most recent call last): File "Lib/test/test_sys.py", line 770, in test_getallocatedblocks alloc_name = _testcapi.pymem_getallocatorsname() RuntimeError: cannot get allocators name
This commit is contained in:
parent
9e4f2f3a6b
commit
9b8314cfe2
2 changed files with 9 additions and 2 deletions
|
@ -767,8 +767,13 @@ class SysModuleTest(unittest.TestCase):
|
|||
except ImportError:
|
||||
with_pymalloc = support.with_pymalloc()
|
||||
else:
|
||||
alloc_name = _testcapi.pymem_getallocatorsname()
|
||||
with_pymalloc = (alloc_name in ('pymalloc', 'pymalloc_debug'))
|
||||
try:
|
||||
alloc_name = _testcapi.pymem_getallocatorsname()
|
||||
except RuntimeError as exc:
|
||||
# "cannot get allocators name" (ex: tracemalloc is used)
|
||||
with_pymalloc = True
|
||||
else:
|
||||
with_pymalloc = (alloc_name in ('pymalloc', 'pymalloc_debug'))
|
||||
|
||||
# Some sanity checks
|
||||
a = sys.getallocatedblocks()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue