diff options
author | Frank Bessou <frank.bessou@logilab.fr> | 2018-07-06 10:38:41 +0200 |
---|---|---|
committer | Frank Bessou <frank.bessou@logilab.fr> | 2018-07-06 10:38:41 +0200 |
commit | 97feba6810f9ab272b834171707a4ae25d81517d (patch) | |
tree | d0f73fcadc512e69da6fdd066786406a6e6dd1a0 | |
parent | 5ca72818af7275b13cbedf2616dad6624597153d (diff) | |
download | logilab-common-97feba6810f9ab272b834171707a4ae25d81517d.tar.gz |
Use getfullargspec instead of getargspec in python 3
In python 3 "getargspec" is deprecated and "getfullargspec" is added.
The only difference between these two functions is that the "keywords"
tuple's field is renamed into "varkw" (which does not impact us in this
case).
-rw-r--r-- | logilab/common/decorators.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/logilab/common/decorators.py b/logilab/common/decorators.py index beafa20..63504ad 100644 --- a/logilab/common/decorators.py +++ b/logilab/common/decorators.py @@ -24,7 +24,14 @@ __docformat__ = "restructuredtext en" import sys import types from time import clock, time -from inspect import isgeneratorfunction, getargspec +from inspect import isgeneratorfunction + +import six + +if six.PY3: + from inspect import getfullargspec +else: + from inspect import getargspec as getfullargspec from logilab.common.compat import method_type @@ -37,7 +44,7 @@ class cached_decorator(object): def __call__(self, callableobj=None): assert not isgeneratorfunction(callableobj), \ 'cannot cache generator function: %s' % callableobj - if len(getargspec(callableobj).args) == 1 or self.keyarg == 0: + if len(getfullargspec(callableobj).args) == 1 or self.keyarg == 0: cache = _SingleValueCache(callableobj, self.cacheattr) elif self.keyarg: cache = _MultiValuesKeyArgCache(callableobj, self.keyarg, self.cacheattr) |