summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2016-10-25 17:30:40 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2016-10-25 08:30:40 -0700
commit7a575d2f4b1c20b61e4f2f847ad3e0a4bf37c0ed (patch)
tree8085e96426403305cc62a7047f18ade3079fa300
parent1928d8325948f00e88f6e01261fe607454beb530 (diff)
downloadspack-7a575d2f4b1c20b61e4f2f847ad3e0a4bf37c0ed.tar.gz
spack-7a575d2f4b1c20b61e4f2f847ad3e0a4bf37c0ed.tar.bz2
spack-7a575d2f4b1c20b61e4f2f847ad3e0a4bf37c0ed.tar.xz
spack-7a575d2f4b1c20b61e4f2f847ad3e0a4bf37c0ed.zip
multimethod.py : calls functools.wraps before returning the correct method fixes #2118 (#2119)
-rw-r--r--lib/spack/spack/multimethod.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/spack/spack/multimethod.py b/lib/spack/spack/multimethod.py
index d1d1f32445..4e2fb3bdaa 100644
--- a/lib/spack/spack/multimethod.py
+++ b/lib/spack/spack/multimethod.py
@@ -105,7 +105,17 @@ class SpecMultiMethod(object):
def __get__(self, obj, objtype):
"""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):
"""Find the first method with a spec that matches the