https://github.com/python/cpython/commit/47d48b62ddfc96d69bd618401132460cbcde6681
commit: 47d48b62ddfc96d69bd618401132460cbcde6681
branch: 3.12
author: Alex Waygood <[email protected]>
committer: AlexWaygood <[email protected]>
date: 2024-11-05T11:19:45Z
summary:

[3.12] gh-126417: Register multiprocessing proxy types to an appropriate 
collections.abc class (#126419) (#126436)

Co-authored-by: Stephen Morton <[email protected]>

files:
A Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst
M Lib/multiprocessing/managers.py
M Lib/test/_test_multiprocessing.py
M Misc/ACKS

diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 75d9c18c201a86..b915e67c265b3d 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -18,6 +18,7 @@
 import threading
 import signal
 import array
+import collections.abc
 import queue
 import time
 import types
@@ -1160,6 +1161,8 @@ def __imul__(self, value):
         return self
 
 
+collections.abc.MutableSequence.register(BaseListProxy)
+
 DictProxy = MakeProxyType('DictProxy', (
     '__contains__', '__delitem__', '__getitem__', '__iter__', '__len__',
     '__setitem__', 'clear', 'copy', 'get', 'items',
@@ -1169,6 +1172,7 @@ def __imul__(self, value):
     '__iter__': 'Iterator',
     }
 
+collections.abc.MutableMapping.register(DictProxy)
 
 ArrayProxy = MakeProxyType('ArrayProxy', (
     '__len__', '__getitem__', '__setitem__'
diff --git a/Lib/test/_test_multiprocessing.py 
b/Lib/test/_test_multiprocessing.py
index 607bfc02b12303..2213af52ca09ac 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -16,6 +16,7 @@
 import functools
 import signal
 import array
+import collections.abc
 import socket
 import random
 import logging
@@ -2331,6 +2332,10 @@ def test_list(self):
         a.append('hello')
         self.assertEqual(f[0][:], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'hello'])
 
+    def test_list_isinstance(self):
+        a = self.list()
+        self.assertIsInstance(a, collections.abc.MutableSequence)
+
     def test_list_iter(self):
         a = self.list(list(range(10)))
         it = iter(a)
@@ -2371,6 +2376,10 @@ def test_dict(self):
         self.assertEqual(sorted(d.values()), [chr(i) for i in indices])
         self.assertEqual(sorted(d.items()), [(i, chr(i)) for i in indices])
 
+    def test_dict_isinstance(self):
+        a = self.dict()
+        self.assertIsInstance(a, collections.abc.MutableMapping)
+
     def test_dict_iter(self):
         d = self.dict()
         indices = list(range(65, 70))
diff --git a/Misc/ACKS b/Misc/ACKS
index 837ffbda18aea1..b5cf6acc55a88c 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1259,6 +1259,7 @@ Emily Morehouse
 Derek Morr
 James A Morrison
 Martin Morrison
+Stephen Morton
 Derek McTavish Mounce
 Alessandro Moura
 Pablo Mouzo
diff --git 
a/Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst 
b/Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst
new file mode 100644
index 00000000000000..c4a366343382f3
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst
@@ -0,0 +1,3 @@
+Register the :class:`!multiprocessing.managers.DictProxy` and 
:class:`!multiprocessing.managers.ListProxy` types in
+:mod:`multiprocessing.managers` to :class:`collections.abc.MutableMapping` and
+:class:`collections.abc.MutableSequence`, respectively.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to