mirror of
https://github.com/python/cpython.git
synced 2025-10-28 12:15:13 +00:00
[3.13] gh-127750: Fix functools.singledispatchmethod() (GH-130029)
Revert gh-107148
This commit is contained in:
parent
30ed4523c0
commit
8f33c7ac17
2 changed files with 2 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue