Skip to content
Snippets Groups Projects
Commit 7a575d2f authored by Massimiliano Culpo's avatar Massimiliano Culpo Committed by Todd Gamblin
Browse files

multimethod.py : calls functools.wraps before returning the correct method fixes #2118 (#2119)

parent 1928d832
No related branches found
No related tags found
No related merge requests found
...@@ -105,7 +105,17 @@ def register(self, spec, method): ...@@ -105,7 +105,17 @@ def register(self, spec, method):
def __get__(self, obj, objtype): def __get__(self, obj, objtype):
"""This makes __call__ support instance methods.""" """This makes __call__ support instance methods."""
return functools.partial(self.__call__, obj) # Method_list is a list of tuples (constraint, method)
# Here we are going to assume that we have at least one
# element in the list. The first registered function
# will be the one 'wrapped'.
wrapped_method = self.method_list[0][1]
# Call functools.wraps manually to get all the attributes
# we need to be disguised as the wrapped_method
func = functools.wraps(wrapped_method)(
functools.partial(self.__call__, obj)
)
return func
def __call__(self, package_self, *args, **kwargs): def __call__(self, package_self, *args, **kwargs):
"""Find the first method with a spec that matches the """Find the first method with a spec that matches the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment