Issue #3125: Remove copy_reg in multiprocessing and replace it with
ForkingPickler.register() to resolve conflict with ctypes.
diff --git a/Lib/multiprocessing/sharedctypes.py b/Lib/multiprocessing/sharedctypes.py
index 45826dd..b94cd52 100644
--- a/Lib/multiprocessing/sharedctypes.py
+++ b/Lib/multiprocessing/sharedctypes.py
@@ -9,10 +9,9 @@
import sys
import ctypes
import weakref
-import copyreg
from multiprocessing import heap, RLock
-from multiprocessing.forking import assert_spawning
+from multiprocessing.forking import assert_spawning, ForkingPickler
__all__ = ['RawValue', 'RawArray', 'Value', 'Array', 'copy', 'synchronized']
@@ -124,8 +123,7 @@
def rebuild_ctype(type_, wrapper, length):
if length is not None:
type_ = type_ * length
- if sys.platform == 'win32' and type_ not in copyreg.dispatch_table:
- copyreg.pickle(type_, reduce_ctype)
+ ForkingPickler.register(type_, reduce_ctype)
obj = type_.from_address(wrapper.get_address())
obj._wrapper = wrapper
return obj