diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 21:39:17 -0400 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 21:39:17 -0400 |
commit | df3f02025c00a7623c6771c454cb3dfb2c29caa5 (patch) | |
tree | d1dfeecb7ee286d828394b2bbfb792f8f3039987 | |
parent | e9094d438c4ae95b3c5cda503d49e14619f5b885 (diff) | |
download | passlib-df3f02025c00a7623c6771c454cb3dfb2c29caa5.tar.gz |
python compat cleanup -- replace stray ".im_func" refs
-rw-r--r-- | passlib/tests/test_utils.py | 11 | ||||
-rw-r--r-- | passlib/utils/decor.py | 10 |
2 files changed, 11 insertions, 10 deletions
diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py index ceea26a..2bc5c48 100644 --- a/passlib/tests/test_utils.py +++ b/passlib/tests/test_utils.py @@ -35,15 +35,18 @@ class MiscTest(TestCase): def test_classproperty(self): from passlib.utils.decor import classproperty + def xprop_func(cls): + return cls.xvar + class test(object): xvar = 1 - @classproperty - def xprop(cls): - return cls.xvar + + xprop = classproperty(xprop_func) self.assertEqual(test.xprop, 1) + prop = test.__dict__['xprop'] - self.assertIs(prop.im_func, prop.__func__) + self.assertIs(prop.__func__, xprop_func) def test_deprecated_function(self): from passlib.utils.decor import deprecated_function diff --git a/passlib/utils/decor.py b/passlib/utils/decor.py index aa40925..e1fd601 100644 --- a/passlib/utils/decor.py +++ b/passlib/utils/decor.py @@ -31,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): """ @@ -48,6 +45,7 @@ class hybrid_method(object): """ def __init__(self, func): + # XXX: rename to .fget to match property? self.func = func update_wrapper(self, func) |