From 76061470b9a96093ebf44c8bb94879558bb1392f Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Wed, 12 Feb 2025 10:36:58 +0100 Subject: [PATCH 1/2] Revert gh-107148 --- Lib/functools.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Lib/functools.py b/Lib/functools.py index 2bc5053bd1b53f..4c1175b815d6ec 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -958,9 +958,6 @@ def __init__(self, func): self.dispatcher = singledispatch(func) self.func = func - import weakref # see comment in singledispatch function - self._method_cache = weakref.WeakKeyDictionary() - def register(self, cls, method=None): """generic_method.register(cls, func) -> func @@ -969,16 +966,6 @@ def register(self, cls, method=None): return self.dispatcher.register(cls, func=method) def __get__(self, obj, cls=None): - if self._method_cache is not None: - try: - _method = self._method_cache[obj] - except TypeError: - self._method_cache = None - except KeyError: - pass - else: - return _method - dispatch = self.dispatcher.dispatch funcname = getattr(self.func, '__name__', 'singledispatchmethod method') def _method(*args, **kwargs): @@ -991,9 +978,6 @@ def _method(*args, **kwargs): _method.register = self.register update_wrapper(_method, self.func) - if self._method_cache is not None: - self._method_cache[obj] = _method - return _method @property From b3064f19af9a522538f084c86060f2a02f8c57d6 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 09:48:31 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-02-12-09-48-25.gh-issue-127750.ibhIZg.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-02-12-09-48-25.gh-issue-127750.ibhIZg.rst diff --git a/Misc/NEWS.d/next/Library/2025-02-12-09-48-25.gh-issue-127750.ibhIZg.rst b/Misc/NEWS.d/next/Library/2025-02-12-09-48-25.gh-issue-127750.ibhIZg.rst new file mode 100644 index 00000000000000..a82805454e45f3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-02-12-09-48-25.gh-issue-127750.ibhIZg.rst @@ -0,0 +1,2 @@ +Remove broken :func:`functools.singledispatchmethod` caching introduced in +:gh:`85160`.