Skip to content

Commit a70ab11

Browse files
committed
Add some more terms for disambiguation.
1 parent adae494 commit a70ab11

File tree

10 files changed

+47
-37
lines changed

10 files changed

+47
-37
lines changed

Doc/c-api/dict.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Dictionary Objects
127127
Prefer the :c:func:`PyDict_GetItemWithError` function instead.
128128
129129
.. versionchanged:: 3.10
130-
Calling this API without an active :term:`thread state` had been allowed for historical
130+
Calling this API without an :term:`attached thread state` had been allowed for historical
131131
reason. It is no longer allowed.
132132
133133

Doc/c-api/exceptions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Querying the error indicator
413413
own a reference to the return value, so you do not need to :c:func:`Py_DECREF`
414414
it.
415415
416-
The caller must have an active :term:`thread state`.
416+
The caller must have an :term:`attached thread state`.
417417
418418
.. note::
419419
@@ -675,7 +675,7 @@ Signal Handling
675675
676676
.. note::
677677
This function is async-signal-safe. It can be called without
678-
an active :term:`thread state` and from a C signal handler.
678+
an :term:`attached thread state` and from a C signal handler.
679679
680680
681681
.. c:function:: int PyErr_SetInterruptEx(int signum)
@@ -702,7 +702,7 @@ Signal Handling
702702
703703
.. note::
704704
This function is async-signal-safe. It can be called without
705-
an active :term:`thread state` and from a C signal handler.
705+
an :term:`attached thread state` and from a C signal handler.
706706
707707
.. versionadded:: 3.10
708708

Doc/c-api/init.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ Initializing and finalizing the interpreter
573573
This is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and
574574
data pointer for the callback.
575575
576-
A :term:`thread state` must be active for *interp*.
576+
There must be an :term:`attached thread state` for *interp*.
577577
578578
.. versionadded:: 3.13
579579
@@ -1206,7 +1206,7 @@ code, or when embedding the Python interpreter:
12061206
12071207
.. c:function:: PyThreadState* PyEval_SaveThread()
12081208
1209-
Detach the active :term:`thread state` (if it has been created) and
1209+
Detach the :term:`active thread state` (if it has been created) and
12101210
return it.
12111211
12121212
@@ -1228,7 +1228,7 @@ code, or when embedding the Python interpreter:
12281228
12291229
.. c:function:: PyThreadState* PyThreadState_Get()
12301230
1231-
Return the active :term:`thread state`. If there is no active :term:`thread state` (such
1231+
Return the :term:`active thread state`. If there is no :term:`active thread state` (such
12321232
as when inside of :c:macro:`Py_BEGIN_ALLOW_THREADS` block), then this issues a fatal
12331233
error (so that the caller needn't check for ``NULL``).
12341234
@@ -1278,7 +1278,7 @@ with sub-interpreters:
12781278
unique call to :c:func:`PyGILState_Ensure` must save the handle for its call
12791279
to :c:func:`PyGILState_Release`.
12801280
1281-
When the function returns, there will be an active :term:`thread state`
1281+
When the function returns, there will be an :term:`attached thread state`
12821282
and the thread will be able to call arbitrary Python code. Failure is a fatal error.
12831283
12841284
.. note::
@@ -1418,7 +1418,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
14181418
14191419
.. c:function:: void PyThreadState_DeleteCurrent(void)
14201420
1421-
Destroy the active :term:`thread state` and detach it.
1421+
Destroy the :term:`active thread state` and detach it.
14221422
The current :term:`thread state` must have been reset with a previous call
14231423
to :c:func:`PyThreadState_Clear`.
14241424
@@ -1482,7 +1482,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
14821482
Issue a fatal error if there no current Python thread state or no current
14831483
interpreter. It cannot return NULL.
14841484
1485-
The caller must have an active :term:`thread state`.
1485+
The caller must have an :term:`attached thread state`.
14861486
14871487
.. versionadded:: 3.9
14881488
@@ -1492,7 +1492,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
14921492
Return the interpreter's unique ID. If there was any error in doing
14931493
so then ``-1`` is returned and an error is set.
14941494
1495-
The caller must have an active :term:`thread state`.
1495+
The caller must have an :term:`attached thread state`.
14961496
14971497
.. versionadded:: 3.7
14981498
@@ -1552,7 +1552,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
15521552
Asynchronously raise an exception in a thread. The *id* argument is the thread
15531553
id of the target thread; *exc* is the exception object to be raised. This
15541554
function does not steal any references to *exc*. To prevent naive misuse, you
1555-
must write your own C extension to call this. Must be called with an active :term:`thread state`.
1555+
must write your own C extension to call this. Must be called with an :term:`attached thread state`.
15561556
Returns the number of thread states modified; this is normally one, but will be
15571557
zero if the thread id isn't found. If *exc* is ``NULL``, the pending
15581558
exception (if any) for the thread is cleared. This raises no exceptions.
@@ -2084,14 +2084,14 @@ Python-level trace functions in previous versions.
20842084
20852085
See also the :func:`sys.setprofile` function.
20862086
2087-
The caller must have an active :term:`thread state`.
2087+
The caller must have an :term:`attached thread state`.
20882088
20892089
.. c:function:: void PyEval_SetProfileAllThreads(Py_tracefunc func, PyObject *obj)
20902090
20912091
Like :c:func:`PyEval_SetProfile` but sets the profile function in all running threads
20922092
belonging to the current interpreter instead of the setting it only on the current thread.
20932093
2094-
The caller must have an active :term:`thread state`.
2094+
The caller must have an :term:`attached thread state`.
20952095
20962096
As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised while
20972097
setting the profile functions in all threads.
@@ -2110,14 +2110,14 @@ Python-level trace functions in previous versions.
21102110
21112111
See also the :func:`sys.settrace` function.
21122112
2113-
The caller must have an active :term:`thread state`.
2113+
The caller must have an :term:`attached thread state`.
21142114
21152115
.. c:function:: void PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *obj)
21162116
21172117
Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running threads
21182118
belonging to the current interpreter instead of the setting it only on the current thread.
21192119
2120-
The caller must have an active :term:`thread state`.
2120+
The caller must have an :term:`attached thread state`.
21212121
21222122
As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised while
21232123
setting the trace functions in all threads.

Doc/c-api/init_config.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ Some options are read from the :mod:`sys` attributes. For example, the option
18931893
* ``list[str]``
18941894
* ``dict[str, str]``
18951895
1896-
The caller must have an active :term:`thread state`. The function cannot
1896+
The caller must have an :term:`attached thread state`. The function cannot
18971897
be called before Python initialization nor after Python finalization.
18981898
18991899
.. versionadded:: 3.14
@@ -1916,7 +1916,7 @@ Some options are read from the :mod:`sys` attributes. For example, the option
19161916
* Return a new reference on success.
19171917
* Set an exception and return ``NULL`` on error.
19181918
1919-
The caller must have an active :term:`thread state`. The function cannot
1919+
The caller must have an :term:`attached thread state`. The function cannot
19201920
be called before Python initialization nor after Python finalization.
19211921
19221922
.. versionadded:: 3.14
@@ -1931,7 +1931,7 @@ Some options are read from the :mod:`sys` attributes. For example, the option
19311931
* Raise a :exc:`ValueError` if the option is read-only (cannot be set).
19321932
* Raise a :exc:`TypeError` if *value* has not the proper type.
19331933
1934-
The caller must have an active :term:`thread state`. The function cannot
1934+
The caller must have an :term:`attached thread state`. The function cannot
19351935
be called before Python initialization nor after Python finalization.
19361936
19371937
.. versionadded:: 3.14

Doc/c-api/memory.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 an active :term:`thread state`. The memory
113+
allocator can operate without an :term:`attached thread state`. The memory
114114
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-
an active :term:`thread state`. 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
@@ -506,7 +506,7 @@ Customize Memory Allocators
506506
:c:func:`Py_InitializeFromConfig` to install a custom memory
507507
allocator. There are no restrictions over the installed allocator
508508
other than the ones imposed by the domain (for instance, the Raw
509-
Domain allows the allocator to be called without an active :term:`thread state`).
509+
Domain allows the allocator to be called without an :term:`attached thread state`).
510510
See :ref:`the section on allocator domains <allocator-domains>` for more
511511
information.
512512

Doc/c-api/module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ since multiple such modules can be created from a single definition.
708708
mechanisms (either by calling it directly, or by referring to its
709709
implementation for details of the required state updates).
710710
711-
The caller must have an active :term:`thread state`.
711+
The caller must have an :term:`attached thread state`.
712712
713713
Return ``-1`` with an exception set on error, ``0`` on success.
714714
@@ -719,6 +719,6 @@ since multiple such modules can be created from a single definition.
719719
Removes the module object created from *def* from the interpreter state.
720720
Return ``-1`` with an exception set on error, ``0`` on success.
721721
722-
The caller must have an active :term:`thread state`.
722+
The caller must have an :term:`attached thread state`.
723723
724724
.. versionadded:: 3.3

Doc/c-api/perfmaps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jit-interface.txt>`_
1616
In Python, these helper APIs can be used by libraries and features that rely
1717
on generating machine code on the fly.
1818

19-
Note that holding an active :term:`thread state` is not required for these APIs.
19+
Note that holding an :term:`attached thread state` is not required for these APIs.
2020

2121
.. c:function:: int PyUnstable_PerfMapState_Init(void)
2222

Doc/c-api/time.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ range.
5656
system time.)
5757

5858
As any other C API (unless otherwise specified), the functions must be called
59-
with an active :term:`thread state`.
59+
with an :term:`attached thread state`.
6060

6161
.. c:function:: int PyTime_Monotonic(PyTime_t *result)
6262
@@ -78,7 +78,7 @@ Raw Clock Functions
7878
-------------------
7979
8080
Similar to clock functions, but don't set an exception on error and don't
81-
require the caller to have an active :term:`thread state`.
81+
require the caller to have an :term:`attached thread state`.
8282
8383
On success, the functions return ``0``.
8484
@@ -90,17 +90,17 @@ the ``Raw`` one failed.
9090
.. c:function:: int PyTime_MonotonicRaw(PyTime_t *result)
9191
9292
Similar to :c:func:`PyTime_Monotonic`,
93-
but don't set an exception on error and don't require an active :term:`thread state`.
93+
but don't set an exception on error and don't require an :term:`attached thread state`.
9494
9595
.. c:function:: int PyTime_PerfCounterRaw(PyTime_t *result)
9696
9797
Similar to :c:func:`PyTime_PerfCounter`,
98-
but don't set an exception on error and don't require an active :term:`thread state`.
98+
but don't set an exception on error and don't require an :term:`attached thread state`.
9999
100100
.. c:function:: int PyTime_TimeRaw(PyTime_t *result)
101101
102102
Similar to :c:func:`PyTime_Time`,
103-
but don't set an exception on error and don't require an active :term:`thread state`.
103+
but don't set an exception on error and don't require an :term:`attached thread state`.
104104
105105
106106
Conversion functions

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
689689
object becomes part of a refcount cycle, that cycle might be collected by
690690
a garbage collection on any thread). This is not a problem for Python
691691
API calls, since the thread on which :c:member:`!tp_dealloc` is called
692-
with an active :term:`thread state`. However, if the object being
692+
with an :term:`attached thread state`. However, if the object being
693693
destroyed in turn destroys objects from some other C or C++ library, care
694694
should be taken to ensure that destroying those objects on the thread
695695
which called :c:member:`!tp_dealloc` will not violate any assumptions of

Doc/glossary.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ Glossary
3636
and loaders (in the :mod:`importlib.abc` module). You can create your own
3737
ABCs with the :mod:`abc` module.
3838

39+
active thread state
40+
41+
The :c:data:`PyThreadState` pointer to a :term:`thread state` for the current thread.
42+
The per-thread pointer might be ``NULL``, in which case Python code should not
43+
get executed. If the active thread state is non-``NULL``, then the :term:`thread state`
44+
that it points to is considered to be :term:`attached <attached thread state>`.
45+
3946
annotate function
4047
A function that can be called to retrieve the :term:`annotations <annotation>`
4148
of an object. This function is accessible as the :attr:`~object.__annotate__`
@@ -132,6 +139,14 @@ Glossary
132139
iterator's :meth:`~object.__anext__` method until it raises a
133140
:exc:`StopAsyncIteration` exception. Introduced by :pep:`492`.
134141

142+
attached thread state
143+
144+
A :term:`thread state` that is :term:`active <active thread state>`
145+
for the current thread.
146+
147+
On most builds of Python, an attached thread state means that the
148+
caller holds the :term:`GIL` for the current interpreter.
149+
135150
attribute
136151
A value associated with an object which is usually referenced by name
137152
using dotted expressions.
@@ -1288,12 +1303,7 @@ Glossary
12881303
thread state
12891304
In Python's C API, a thread state is a structure that holds
12901305
information about the current thread. A thread state must be
1291-
active for the current thread in order to call most of the C API.
1292-
1293-
On most builds of Python, an attached thread state means that the
1294-
caller holds the :term:`GIL` for the current interpreter, but on
1295-
:term:`free-threaded <free-threading>` builds, multiple thread states
1296-
can be active at once.
1306+
:term:`active <active thread state>` for the current thread in order to call most of the C API.
12971307

12981308
See :ref:`Thread State and the Global Interpreter Lock <threads>` for more
12991309
information.

0 commit comments

Comments
 (0)