@@ -933,7 +933,7 @@ def __init__(self, func):
933
933
934
934
self .dispatcher = singledispatch (func )
935
935
self .func = func
936
- self .attrname = None
936
+ self ._dispatch_method = None
937
937
938
938
def register (self , cls , method = None ):
939
939
"""generic_method.register(cls, func) -> func
@@ -943,25 +943,22 @@ def register(self, cls, method=None):
943
943
return self .dispatcher .register (cls , func = method )
944
944
945
945
def __get__ (self , obj , cls = None ):
946
+ if self ._dispatch_method :
947
+ return self ._dispatch_method
948
+
946
949
def _method (* args , ** kwargs ):
947
950
method = self .dispatcher .dispatch (args [0 ].__class__ )
948
951
return method .__get__ (obj , cls )(* args , ** kwargs )
949
952
950
953
_method .__isabstractmethod__ = self .__isabstractmethod__
951
954
_method .register = self .register
952
955
update_wrapper (_method , self .func )
953
- if obj is not None :
954
- # we set the method directly to the instance
955
- obj .__dict__ [self .attrname ] = _method
956
956
return _method
957
957
958
958
@property
959
959
def __isabstractmethod__ (self ):
960
960
return getattr (self .func , '__isabstractmethod__' , False )
961
961
962
- def __set_name__ (self , owner , name ):
963
- if self .attrname is None :
964
- self .attrname = name
965
962
966
963
967
964
################################################################################
0 commit comments