Skip to content

Commit 6c955e0

Browse files
committed
Fix up list iteration for FT build
1 parent 981d8e9 commit 6c955e0

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

Diff for: Python/bytecodes.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -3196,8 +3196,7 @@ dummy_func(
31963196
EXIT_IF(Py_TYPE(iter_o) != &PyList_Type);
31973197
assert(PyStackRef_IsTaggedInt(null_or_index));
31983198
#ifdef Py_GIL_DISABLED
3199-
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) ||
3200-
!_PyObject_GC_IS_SHARED(iter_o));
3199+
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) && !_PyObject_GC_IS_SHARED(iter_o));
32013200
#endif
32023201
}
32033202

Diff for: Python/executor_cases.c.h

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Python/generated_cases.c.h

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Python/specialize.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -2902,13 +2902,10 @@ _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT
29022902
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
29032903
PyTypeObject *tp = Py_TYPE(iter_o);
29042904
#ifdef Py_GIL_DISABLED
2905-
// Only specialize for uniquely referenced iterators, so that we know
2906-
// they're only referenced by this one thread. This is more limiting
2907-
// than we need (even `it = iter(mylist); for item in it:` won't get
2908-
// specialized) but we don't have a way to check whether we're the only
2909-
// _thread_ who has access to the object.
2910-
if (!_PyObject_IsUniquelyReferenced(iter_o))
2905+
// Only specialize for lists owned by this thread or shared
2906+
if (!_Py_IsOwnedByCurrentThread(iter_o) && !_PyObject_GC_IS_SHARED(iter_o)) {
29112907
goto failure;
2908+
}
29122909
#endif
29132910
if (PyStackRef_IsNull(null_or_index)) {
29142911
if (tp == &PyRangeIter_Type) {

0 commit comments

Comments
 (0)