From 9705e20a799737e2f06722dd3d67063a491d7378 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 12 Nov 2024 11:54:47 +0000 Subject: [PATCH 1/2] Revert "[3.13] gh-126451: Register contextvars.Context to collections.abc.Mapping (GH-126452) (#126518)" This reverts commit 59316a668ec17374640cdd5fdd73fa2ca23f66b5. --- Lib/contextvars.py | 4 ---- Lib/test/test_context.py | 14 -------------- .../2024-11-05-11-28-45.gh-issue-126451.XJMtqz.rst | 2 -- 3 files changed, 20 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2024-11-05-11-28-45.gh-issue-126451.XJMtqz.rst diff --git a/Lib/contextvars.py b/Lib/contextvars.py index 14514f185e069d..d78c80dfe6f99c 100644 --- a/Lib/contextvars.py +++ b/Lib/contextvars.py @@ -1,8 +1,4 @@ -import _collections_abc from _contextvars import Context, ContextVar, Token, copy_context __all__ = ('Context', 'ContextVar', 'Token', 'copy_context') - - -_collections_abc.Mapping.register(Context) diff --git a/Lib/test/test_context.py b/Lib/test/test_context.py index 3fa8615e2782ad..255be306156c0b 100644 --- a/Lib/test/test_context.py +++ b/Lib/test/test_context.py @@ -1,4 +1,3 @@ -import collections.abc import concurrent.futures import contextvars import functools @@ -343,19 +342,6 @@ def ctx2_fun(): ctx1.run(ctx1_fun) - def test_context_isinstance(self): - ctx = contextvars.Context() - self.assertIsInstance(ctx, collections.abc.Mapping) - self.assertTrue(issubclass(contextvars.Context, collections.abc.Mapping)) - - mapping_methods = ( - '__contains__', '__eq__', '__getitem__', '__iter__', '__len__', - '__ne__', 'get', 'items', 'keys', 'values', - ) - for name in mapping_methods: - with self.subTest(name=name): - self.assertTrue(callable(getattr(ctx, name))) - @isolated_context @threading_helper.requires_working_threading() def test_context_threads_1(self): diff --git a/Misc/NEWS.d/next/Library/2024-11-05-11-28-45.gh-issue-126451.XJMtqz.rst b/Misc/NEWS.d/next/Library/2024-11-05-11-28-45.gh-issue-126451.XJMtqz.rst deleted file mode 100644 index 563cb2515eca60..00000000000000 --- a/Misc/NEWS.d/next/Library/2024-11-05-11-28-45.gh-issue-126451.XJMtqz.rst +++ /dev/null @@ -1,2 +0,0 @@ -Register the :class:`contextvars.Context` type to -:class:`collections.abc.Mapping`. From bf7cb54ae7453478f734ec961d938e186f001b01 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 12 Nov 2024 11:55:53 +0000 Subject: [PATCH 2/2] Revert "[3.13] gh-126417: Register multiprocessing proxy types to an appropriate collections.abc class (#126419) (#126435)" This reverts commit c1e708ab070a08a4427e230dd9127138d527ceef. --- Lib/multiprocessing/managers.py | 3 --- Lib/test/_test_multiprocessing.py | 9 --------- Misc/ACKS | 1 - .../2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst | 3 --- 4 files changed, 16 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py index 684ebaa9549b16..76b915de74d94e 100644 --- a/Lib/multiprocessing/managers.py +++ b/Lib/multiprocessing/managers.py @@ -18,7 +18,6 @@ import threading import signal import array -import collections.abc import queue import time import types @@ -1168,7 +1167,6 @@ def __imul__(self, value): __class_getitem__ = classmethod(types.GenericAlias) -collections.abc.MutableSequence.register(BaseListProxy) _BaseDictProxy = MakeProxyType('DictProxy', ( '__contains__', '__delitem__', '__getitem__', '__iter__', '__len__', @@ -1181,7 +1179,6 @@ def __imul__(self, value): class DictProxy(_BaseDictProxy): __class_getitem__ = classmethod(types.GenericAlias) -collections.abc.MutableMapping.register(_BaseDictProxy) ArrayProxy = MakeProxyType('ArrayProxy', ( '__len__', '__getitem__', '__setitem__' diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 5083f371e10d47..ce93d94699ce78 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -17,7 +17,6 @@ import functools import signal import array -import collections.abc import socket import random import logging @@ -2460,10 +2459,6 @@ 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) @@ -2504,10 +2499,6 @@ 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 0d76e1a2137bee..05cb6874759c31 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1270,7 +1270,6 @@ 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 deleted file mode 100644 index c4a366343382f3..00000000000000 --- a/Misc/NEWS.d/next/Library/2024-11-04-16-40-02.gh-issue-126417.OWPqn0.rst +++ /dev/null @@ -1,3 +0,0 @@ -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.