mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-123471: Make itertools.chain thread-safe (#135689)
This commit is contained in:
parent
536a5ff153
commit
0533c1faf2
3 changed files with 43 additions and 4 deletions
|
@ -1880,8 +1880,8 @@ chain_traverse(PyObject *op, visitproc visit, void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
chain_next(PyObject *op)
|
||||
static inline PyObject *
|
||||
chain_next_lock_held(PyObject *op)
|
||||
{
|
||||
chainobject *lz = chainobject_CAST(op);
|
||||
PyObject *item;
|
||||
|
@ -1919,6 +1919,16 @@ chain_next(PyObject *op)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
chain_next(PyObject *op)
|
||||
{
|
||||
PyObject *result;
|
||||
Py_BEGIN_CRITICAL_SECTION(op);
|
||||
result = chain_next_lock_held(op);
|
||||
Py_END_CRITICAL_SECTION()
|
||||
return result;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(chain_doc,
|
||||
"chain(*iterables)\n\
|
||||
--\n\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue