summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-01 10:03:26 +0100
committerVictor Stinner <victor.stinner@gmail.com>2013-12-01 10:03:26 +0100
commit7049e92e939bfdb1d9e34a8d3a5d1611d8fd1a4a (patch)
tree616d8d2a4ca7e0f8742d4cf8f17150bce9eb816e /Python/pythonrun.c
parente90b63bb003a4339ac5243d7728fbd2792d4fe8f (diff)
downloadcpython-7049e92e939bfdb1d9e34a8d3a5d1611d8fd1a4a.tar.gz
Closes #19831: Stop tracemalloc later at Python shutdown to be able to use
tracemalloc in objects destructor Replace atexit handler with an harcoded C function _PyTraceMalloc_Fini().
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 3adbbd7373..ccf82af36b 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -106,6 +106,7 @@ extern int _PyFaulthandler_Init(void);
extern void _PyFaulthandler_Fini(void);
extern void _PyHash_Fini(void);
extern int _PyTraceMalloc_Init(void);
+extern int _PyTraceMalloc_Fini(void);
#ifdef WITH_THREAD
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
@@ -642,6 +643,10 @@ Py_Finalize(void)
PyGC_Collect();
#endif
+ /* Disable tracemalloc after all Python objects have been destroyed,
+ so it is possible to use tracemalloc in objects destructor. */
+ _PyTraceMalloc_Fini();
+
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
_PyImport_Fini();