Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/multiprocessing/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def __isub__(self, value):

__class_getitem__ = classmethod(types.GenericAlias)

collections.abc.MutableMapping.register(_BaseSetProxy)
collections.abc.MutableSet.register(_BaseSetProxy)


ArrayProxy = MakeProxyType('ArrayProxy', (
Expand Down
24 changes: 24 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2786,6 +2786,29 @@ def test_dict_proxy_nested(self):
self.assertIsInstance(outer[0], list) # Not a ListProxy
self.assertEqual(outer[-1][-1]['feed'], 3)

def test_set_isinstance(self):
s = self.set()
self.assertIsInstance(s, collections.abc.MutableSet)
self.assertNotIsInstance(s, collections.abc.MutableMapping)

mutable_set_methods = (
'__contains__', '__iter__', '__len__',
'add', 'discard', 'remove', 'pop', 'clear',
'update', 'difference_update', 'intersection_update',
'symmetric_difference_update',
)
for name in mutable_set_methods:
with self.subTest(name=name):
self.assertTrue(callable(getattr(s, name)))

mapping_only_methods = (
'__getitem__', '__setitem__', 'setdefault',
'keys', 'items', 'values', 'get',
)
for name in mapping_only_methods:
with self.subTest(name=name):
self.assertFalse(hasattr(s, name))

def test_nested_queue(self):
a = self.list() # Test queue inside list
a.append(self.Queue())
Expand Down Expand Up @@ -7131,6 +7154,7 @@ class ManagerMixin(BaseMixin):
Array = property(operator.attrgetter('manager.Array'))
list = property(operator.attrgetter('manager.list'))
dict = property(operator.attrgetter('manager.dict'))
set = property(operator.attrgetter('manager.set'))
Namespace = property(operator.attrgetter('manager.Namespace'))

@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Register ``multiprocessing.managers.SetProxy`` as ``collections.abc.MutableSet`` rather than ``MutableMapping``.
Loading