Skip to content

Commit ff7266e

Browse files
bpo-43959: clarify the documentation of the PyContextVar C-API (pythonGH-25671) (pythonGH-25690)
(cherry picked from commit 4c49be7)
1 parent 77db337 commit ff7266e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Doc/c-api/contextvars.rst

+6-7
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ Context variable functions:
112112
.. c:function:: PyObject *PyContextVar_New(const char *name, PyObject *def)
113113
114114
Create a new ``ContextVar`` object. The *name* parameter is used
115-
for introspection and debug purposes. The *def* parameter may optionally
116-
specify the default value for the context variable. If an error has
117-
occurred, this function returns ``NULL``.
115+
for introspection and debug purposes. The *def* parameter specifies
116+
a default value for the context variable, or ``NULL`` for no default.
117+
If an error has occurred, this function returns ``NULL``.
118118
119119
.. c:function:: int PyContextVar_Get(PyObject *var, PyObject *default_value, PyObject **value)
120120
@@ -129,13 +129,12 @@ Context variable functions:
129129
- the default value of *var*, if not ``NULL``;
130130
- ``NULL``
131131
132-
If the value was found, the function will create a new reference to it.
132+
Except for ``NULL``, the function returns a new reference.
133133
134134
.. c:function:: PyObject *PyContextVar_Set(PyObject *var, PyObject *value)
135135
136-
Set the value of *var* to *value* in the current context. Returns a
137-
pointer to a :c:type:`PyObject` object, or ``NULL`` if an error
138-
has occurred.
136+
Set the value of *var* to *value* in the current context. Returns
137+
a new token object for this change, or ``NULL`` if an error has occurred.
139138
140139
.. c:function:: int PyContextVar_Reset(PyObject *var, PyObject *token)
141140
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)