diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-16 11:20:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 11:20:31 (GMT) |
commit | ccb0442a338066bf40fe417455e5a374e5238afb (patch) | |
tree | 155b84289b5136d624ebd3577902ee1435a6b4e1 /Python | |
parent | 05cb728d68a278d11466f9a6c8258d914135c96c (diff) | |
download | cpython-ccb0442a338066bf40fe417455e5a374e5238afb.zip cpython-ccb0442a338066bf40fe417455e5a374e5238afb.tar.gz cpython-ccb0442a338066bf40fe417455e5a374e5238afb.tar.bz2 |
bpo-32043: New "developer mode": "-X dev" option (#4413)
Add a new "developer mode": new "-X dev" command line option to
enable debug checks at runtime.
Changes:
* Add unit tests for -X dev
* test_cmd_line: replace test.support with support.
* Fix _PyRuntimeState_Fini(): Use the same memory allocator
than _PyRuntimeState_Init().
* Fix _PyMem_GetDefaultRawAllocator()
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pystate.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 4544de9..807ac4e 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -64,10 +64,18 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime) void _PyRuntimeState_Fini(_PyRuntimeState *runtime) { + /* Use the same memory allocator than _PyRuntimeState_Init() */ + PyMemAllocatorEx old_alloc, raw_alloc; + PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); + _PyMem_GetDefaultRawAllocator(&raw_alloc); + PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &raw_alloc); + if (runtime->interpreters.mutex != NULL) { PyThread_free_lock(runtime->interpreters.mutex); runtime->interpreters.mutex = NULL; } + + PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); } #define HEAD_LOCK() PyThread_acquire_lock(_PyRuntime.interpreters.mutex, \ |