Skip to content

Commit 4c49be7

Browse files
authored
bpo-43959: clarify the documentation of the PyContextVar C-API (GH-25671)
Automerge-Triggered-By: GH:scoder
1 parent fe52eb6 commit 4c49be7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Doc/c-api/contextvars.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ Context variable functions:
107107
.. c:function:: PyObject *PyContextVar_New(const char *name, PyObject *def)
108108
109109
Create a new ``ContextVar`` object. The *name* parameter is used
110-
for introspection and debug purposes. The *def* parameter may optionally
111-
specify the default value for the context variable. If an error has
112-
occurred, this function returns ``NULL``.
110+
for introspection and debug purposes. The *def* parameter specifies
111+
a default value for the context variable, or ``NULL`` for no default.
112+
If an error has occurred, this function returns ``NULL``.
113113
114114
.. c:function:: int PyContextVar_Get(PyObject *var, PyObject *default_value, PyObject **value)
115115
@@ -124,13 +124,12 @@ Context variable functions:
124124
- the default value of *var*, if not ``NULL``;
125125
- ``NULL``
126126
127-
If the value was found, the function will create a new reference to it.
127+
Except for ``NULL``, the function returns a new reference.
128128
129129
.. c:function:: PyObject *PyContextVar_Set(PyObject *var, PyObject *value)
130130
131-
Set the value of *var* to *value* in the current context. Returns a
132-
pointer to a :c:type:`PyObject` object, or ``NULL`` if an error
133-
has occurred.
131+
Set the value of *var* to *value* in the current context. Returns
132+
a new token object for this change, or ``NULL`` if an error has occurred.
134133
135134
.. c:function:: int PyContextVar_Reset(PyObject *var, PyObject *token)
136135
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The documentation on the PyContextVar C-API was clarified.

0 commit comments

Comments
 (0)