@@ -216,7 +216,7 @@ get_reentrant(void)
216
216
static void
217
217
set_reentrant (int reentrant )
218
218
{
219
- assert (! reentrant || ! get_reentrant () );
219
+ assert (reentrant != tracemalloc_reentrant );
220
220
tracemalloc_reentrant = reentrant ;
221
221
}
222
222
#endif
@@ -879,10 +879,6 @@ tracemalloc_clear_traces(void)
879
879
assert (PyGILState_Check ());
880
880
#endif
881
881
882
- /* Disable also reentrant calls to tracemalloc_malloc() to not add a new
883
- trace while we are clearing traces */
884
- assert (get_reentrant ());
885
-
886
882
TABLES_LOCK ();
887
883
_Py_hashtable_clear (tracemalloc_traces );
888
884
tracemalloc_traced_memory = 0 ;
@@ -971,11 +967,6 @@ tracemalloc_init(void)
971
967
tracemalloc_empty_traceback .frames [0 ].lineno = 0 ;
972
968
tracemalloc_empty_traceback .hash = traceback_hash (& tracemalloc_empty_traceback );
973
969
974
- /* Disable tracing allocations until hooks are installed. Set
975
- also the reentrant flag to detect bugs: fail with an assertion error
976
- if set_reentrant(1) is called while tracing is disabled. */
977
- set_reentrant (1 );
978
-
979
970
tracemalloc_config .initialized = TRACEMALLOC_INITIALIZED ;
980
971
return 0 ;
981
972
}
@@ -1063,7 +1054,6 @@ tracemalloc_start(int max_nframe)
1063
1054
1064
1055
/* everything is ready: start tracing Python memory allocations */
1065
1056
tracemalloc_config .tracing = 1 ;
1066
- set_reentrant (0 );
1067
1057
1068
1058
return 0 ;
1069
1059
}
@@ -1078,10 +1068,6 @@ tracemalloc_stop(void)
1078
1068
/* stop tracing Python memory allocations */
1079
1069
tracemalloc_config .tracing = 0 ;
1080
1070
1081
- /* set the reentrant flag to detect bugs: fail with an assertion error if
1082
- set_reentrant(1) is called while tracing is disabled. */
1083
- set_reentrant (1 );
1084
-
1085
1071
/* unregister the hook on memory allocators */
1086
1072
#ifdef TRACE_RAW_MALLOC
1087
1073
PyMem_SetAllocator (PYMEM_DOMAIN_RAW , & allocators .raw );
0 commit comments