mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-32030: Rework memory allocators (#4625)
* Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
This commit is contained in:
parent
c15bb49d71
commit
5d39e04290
14 changed files with 405 additions and 171 deletions
|
@ -753,8 +753,15 @@ class SysModuleTest(unittest.TestCase):
|
|||
@unittest.skipUnless(hasattr(sys, "getallocatedblocks"),
|
||||
"sys.getallocatedblocks unavailable on this build")
|
||||
def test_getallocatedblocks(self):
|
||||
try:
|
||||
import _testcapi
|
||||
except ImportError:
|
||||
with_pymalloc = support.with_pymalloc()
|
||||
else:
|
||||
alloc_name = _testcapi.pymem_getallocatorsname()
|
||||
with_pymalloc = (alloc_name in ('pymalloc', 'pymalloc_debug'))
|
||||
|
||||
# Some sanity checks
|
||||
with_pymalloc = sysconfig.get_config_var('WITH_PYMALLOC')
|
||||
a = sys.getallocatedblocks()
|
||||
self.assertIs(type(a), int)
|
||||
if with_pymalloc:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue