diff options
Diffstat (limited to 'passlib/utils/decor.py')
-rw-r--r-- | passlib/utils/decor.py | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/passlib/utils/decor.py b/passlib/utils/decor.py index 9041d5d..e1fd601 100644 --- a/passlib/utils/decor.py +++ b/passlib/utils/decor.py @@ -5,7 +5,6 @@ passlib.utils.decor -- helper decorators & properties # imports #============================================================================= # core -from __future__ import absolute_import, division, print_function import logging log = logging.getLogger(__name__) from functools import wraps, update_wrapper @@ -13,7 +12,6 @@ import types from warnings import warn # site # pkg -from passlib.utils.compat import PY3 # local __all__ = [ "classproperty", @@ -33,15 +31,12 @@ class classproperty(object): """Function decorator which acts like a combination of classmethod+property (limited to read-only properties)""" def __init__(self, func): - self.im_func = func + # XXX: rename to .fget to match property? + self.__func__ = func def __get__(self, obj, cls): - return self.im_func(cls) + return self.__func__(cls) - @property - def __func__(self): - """py3 compatible alias""" - return self.im_func class hybrid_method(object): """ @@ -50,16 +45,14 @@ class hybrid_method(object): """ def __init__(self, func): + # XXX: rename to .fget to match property? self.func = func update_wrapper(self, func) def __get__(self, obj, cls): if obj is None: obj = cls - if PY3: - return types.MethodType(self.func, obj) - else: - return types.MethodType(self.func, obj, cls) + return types.MethodType(self.func, obj) #============================================================================= # memoization @@ -104,13 +97,6 @@ class memoized_property(object): setattr(obj, self.__name__, value) return value - if not PY3: - - @property - def im_func(self): - """py2 alias""" - return self.__func__ - def clear_cache(self, obj): """ class-level helper to clear stored value (if any). @@ -174,8 +160,7 @@ def deprecated_function(msg=None, deprecated=None, removed=None, updoc=True, def build(func): is_classmethod = _is_method and isinstance(func, classmethod) if is_classmethod: - # NOTE: PY26 doesn't support "classmethod().__func__" directly... - func = func.__get__(None, type).__func__ + func = func.__func__ opts = dict( mod=func_module or func.__module__, name=func.__name__, |