Skip to content

Commit 8d720d8

Browse files
committed
don't add __iter__ to ListProxy, add a note to the test
1 parent 36cf88b commit 8d720d8

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Lib/multiprocessing/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ def set(self, value):
11541154

11551155
BaseListProxy = MakeProxyType('BaseListProxy', (
11561156
'__add__', '__contains__', '__delitem__', '__getitem__', '__imul__',
1157-
'__iter__', '__len__', '__mul__', '__reversed__', '__rmul__', '__setitem__',
1157+
'__len__', '__mul__', '__reversed__', '__rmul__', '__setitem__',
11581158
'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop',
11591159
'remove', 'reverse', 'sort',
11601160
))

Lib/test/_test_multiprocessing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,9 +2336,12 @@ def test_list_isinstance(self):
23362336
a = self.list()
23372337
self.assertIsInstance(a, collections.abc.MutableSequence)
23382338

2339+
# MutableSequence also has __iter__, but we can iterate over
2340+
# ListProxy using __getitem__ instead. Adding __iter__ to ListProxy
2341+
# would change the behavior of a list modified during iteration.
23392342
mutable_sequence_methods = (
23402343
'__contains__', '__delitem__', '__getitem__', '__iadd__',
2341-
'__iter__', '__len__', '__reversed__', '__setitem__', 'append',
2344+
'__len__', '__reversed__', '__setitem__', 'append',
23422345
'clear', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
23432346
'reverse',
23442347
)

Misc/NEWS.d/next/Library/2024-11-05-12-24-49.gh-issue-126417.VrKYyJ.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)