Skip to content

Commit f11e1ee

Browse files
committed
gh-142918: Fix Context docstrings to say iterator instead of list
The Context.items(), Context.keys(), and Context.values() methods return iterators, not lists. Updated the docstrings in both the C source and the documentation to accurately reflect this behavior. Files modified: - Python/context.c: Updated clinic input docstrings - Python/clinic/context.c.h: Regenerated by clinic tool - Doc/library/contextvars.rst: Updated documentation
1 parent daa9aa4 commit f11e1ee

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Doc/library/contextvars.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,16 @@ Manual Context Management
275275

276276
.. method:: keys()
277277

278-
Return a list of all variables in the context object.
278+
Return an iterator of all variables in the context object.
279279

280280
.. method:: values()
281281

282-
Return a list of all variables' values in the context object.
282+
Return an iterator of all variables' values in the context object.
283283

284284

285285
.. method:: items()
286286

287-
Return a list of 2-tuples containing all variables and their
287+
Return an iterator of 2-tuples containing all variables and their
288288
values in the context object.
289289

290290

Python/clinic/context.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/context.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,12 @@ _contextvars.Context.items
650650
651651
Return all variables and their values in the context object.
652652
653-
The result is returned as a list of 2-tuples (variable, value).
653+
The result is returned as an iterator of 2-tuples (variable, value).
654654
[clinic start generated code]*/
655655

656656
static PyObject *
657657
_contextvars_Context_items_impl(PyContext *self)
658-
/*[clinic end generated code: output=fa1655c8a08502af input=00db64ae379f9f42]*/
658+
/*[clinic end generated code: output=fa1655c8a08502af input=f9c1fe4d39962ea0]*/
659659
{
660660
return _PyHamt_NewIterItems(self->ctx_vars);
661661
}
@@ -664,12 +664,12 @@ _contextvars_Context_items_impl(PyContext *self)
664664
/*[clinic input]
665665
_contextvars.Context.keys
666666
667-
Return a list of all variables in the context object.
667+
Return an iterator of all variables in the context object.
668668
[clinic start generated code]*/
669669

670670
static PyObject *
671671
_contextvars_Context_keys_impl(PyContext *self)
672-
/*[clinic end generated code: output=177227c6b63ec0e2 input=114b53aebca3449c]*/
672+
/*[clinic end generated code: output=177227c6b63ec0e2 input=f806e4e5f77c7e7e]*/
673673
{
674674
return _PyHamt_NewIterKeys(self->ctx_vars);
675675
}
@@ -678,12 +678,12 @@ _contextvars_Context_keys_impl(PyContext *self)
678678
/*[clinic input]
679679
_contextvars.Context.values
680680
681-
Return a list of all variables' values in the context object.
681+
Return an iterator of all variables' values in the context object.
682682
[clinic start generated code]*/
683683

684684
static PyObject *
685685
_contextvars_Context_values_impl(PyContext *self)
686-
/*[clinic end generated code: output=d286dabfc8db6dde input=ce8075d04a6ea526]*/
686+
/*[clinic end generated code: output=d286dabfc8db6dde input=6f3cb30499d55021]*/
687687
{
688688
return _PyHamt_NewIterValues(self->ctx_vars);
689689
}

0 commit comments

Comments
 (0)