Skip to content

Commit 88562ec

Browse files
committed
Fix up list iteration for FT build
1 parent aa62e39 commit 88562ec

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,8 +3202,7 @@ dummy_func(
32023202
EXIT_IF(Py_TYPE(iter_o) != &PyList_Type);
32033203
assert(PyStackRef_IsTaggedInt(null_or_index));
32043204
#ifdef Py_GIL_DISABLED
3205-
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) ||
3206-
!_PyObject_GC_IS_SHARED(iter_o));
3205+
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) && !_PyObject_GC_IS_SHARED(iter_o));
32073206
#endif
32083207
}
32093208

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/specialize.c

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

0 commit comments

Comments
 (0)