Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f33c7a

Browse files
authored
[3.13] gh-127750: Fix functools.singledispatchmethod() (GH-130029)
Revert gh-107148
1 parent 30ed452 commit 8f33c7a

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

Lib/functools.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,6 @@ def __init__(self, func):
958958
self.dispatcher = singledispatch(func)
959959
self.func = func
960960

961-
import weakref # see comment in singledispatch function
962-
self._method_cache = weakref.WeakKeyDictionary()
963-
964961
def register(self, cls, method=None):
965962
"""generic_method.register(cls, func) -> func
966963
@@ -969,16 +966,6 @@ def register(self, cls, method=None):
969966
return self.dispatcher.register(cls, func=method)
970967

971968
def __get__(self, obj, cls=None):
972-
if self._method_cache is not None:
973-
try:
974-
_method = self._method_cache[obj]
975-
except TypeError:
976-
self._method_cache = None
977-
except KeyError:
978-
pass
979-
else:
980-
return _method
981-
982969
dispatch = self.dispatcher.dispatch
983970
funcname = getattr(self.func, '__name__', 'singledispatchmethod method')
984971
def _method(*args, **kwargs):
@@ -991,9 +978,6 @@ def _method(*args, **kwargs):
991978
_method.register = self.register
992979
update_wrapper(_method, self.func)
993980

994-
if self._method_cache is not None:
995-
self._method_cache[obj] = _method
996-
997981
return _method
998982

999983
@property
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove broken :func:`functools.singledispatchmethod` caching introduced in
2+
:gh:`85160`.

0 commit comments

Comments
 (0)