@@ -110,12 +110,12 @@ The three allocation domains are:
110110
111111* Raw domain: intended for allocating memory for general-purpose memory
112112  buffers where the allocation *must * go to the system allocator or where the
113-   allocator can operate without the  :term: `GIL `. The memory is requested directly 
114-   from the system. See :ref: `Raw Memory Interface  <raw-memoryinterface >`.
113+   allocator can operate without an  :term: `attached thread state `. The memory
114+   is requested directly  from the system. See :ref: `Raw Memory Interface  <raw-memoryinterface >`.
115115
116116* "Mem" domain: intended for allocating memory for Python buffers and
117117  general-purpose memory buffers where the allocation must be performed with
118-   the  :term: `GIL ` held . The memory is taken from the Python private heap.
118+   an  :term: `attached thread state ` . The memory is taken from the Python private heap.
119119  See :ref: `Memory Interface  <memoryinterface >`.
120120
121121* Object domain: intended for allocating memory for Python objects. The
@@ -139,8 +139,8 @@ Raw Memory Interface
139139==================== 
140140
141141The following function sets are wrappers to the system allocator. These
142- functions are thread-safe, the  :term: `GIL <global interpreter lock> ` does not
143- need to be held .
142+ functions are thread-safe, so a  :term: `thread state ` does not
143+ need to be :term: ` attached <attached thread state> ` .
144144
145145The :ref: `default raw memory allocator  <default-memory-allocators >` uses
146146the following functions: :c:func: `malloc `, :c:func: `calloc `, :c:func: `realloc `
@@ -213,8 +213,7 @@ The :ref:`default memory allocator <default-memory-allocators>` uses the
213213
214214.. warning :: 
215215
216-    The :term: `GIL <global interpreter lock> ` must be held when using these 
217-    functions. 
216+    There must be an :term: `attached thread state ` when using these functions. 
218217
219218.. versionchanged :: 3.6  
220219
@@ -327,8 +326,7 @@ The :ref:`default object allocator <default-memory-allocators>` uses the
327326
328327.. warning :: 
329328
330-    The :term: `GIL <global interpreter lock> ` must be held when using these 
331-    functions. 
329+    There must be an :term: `attached thread state ` when using these functions. 
332330
333331.. c :function :: void * PyObject_Malloc (size_t n)  
334332
@@ -485,12 +483,12 @@ Customize Memory Allocators
485483   zero bytes. 
486484
487485   For the :c:macro: `PYMEM_DOMAIN_RAW ` domain, the allocator must be 
488-    thread-safe: the  :term: `GIL <global interpreter lock> ` is not held when the  
489-    allocator is called. 
486+    thread-safe: a  :term: `thread state ` is not :term: ` attached <attached thread state> `  
487+    when the  allocator is called. 
490488
491489   For the remaining domains, the allocator must also be thread-safe: 
492490   the allocator may be called in different interpreters that do not 
493-    share a `` GIL ` `. 
491+    share a :term: ` GIL `. 
494492
495493   If the new allocator is not a hook (does not call the previous allocator), 
496494   the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the 
@@ -507,8 +505,8 @@ Customize Memory Allocators
507505         :c:func:`Py_InitializeFromConfig` to install a custom memory 
508506         allocator. There are no restrictions over the installed allocator 
509507         other than the ones imposed by the domain (for instance, the Raw 
510-          Domain allows the allocator to be called without the GIL held). See  
511-          :ref:`the section on allocator domains <allocator-domains>` for more 
508+          Domain allows the allocator to be called without an  :term: ` attached thread state `).  
509+          See  :ref:`the section on allocator domains <allocator-domains>` for more 
512510         information. 
513511
514512       * If called after Python has finish initializing (after 
@@ -555,7 +553,7 @@ Runtime checks:
555553  called on a memory block allocated by :c:func:`PyMem_Malloc`. 
556554- Detect write before the start of the buffer (buffer underflow). 
557555- Detect write after the end of the buffer (buffer overflow). 
558- - Check that the  :term:`GIL <global interpreter lock>` is held  when 
556+ - Check that there is an  :term:`attached thread state`  when 
559557  allocator functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: 
560558  :c:func: `PyObject_Malloc `) and :c:macro:`PYMEM_DOMAIN_MEM` (ex: 
561559  :c:func: `PyMem_Malloc `) domains are called. 
@@ -620,8 +618,8 @@ PYMEM_CLEANBYTE (meaning uninitialized memory is getting used).
620618   The :c:func:`PyMem_SetupDebugHooks` function now also works on Python 
621619   compiled in release mode.  On error, the debug hooks now use 
622620   :mod:`tracemalloc` to get the traceback where a memory block was allocated. 
623-    The debug hooks now also check if the GIL  is held when functions of  
624-    :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are 
621+    The debug hooks now also check if there  is an :term:`attached thread state` when  
622+    functions of  :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are 
625623   called. 
626624
627625.. versionchanged:: 3.8 
0 commit comments