summaryrefslogtreecommitdiff
path: root/passlib/ext/django/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/ext/django/utils.py')
-rw-r--r--passlib/ext/django/utils.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/passlib/ext/django/utils.py b/passlib/ext/django/utils.py
index 2f8a2ef..d25a501 100644
--- a/passlib/ext/django/utils.py
+++ b/passlib/ext/django/utils.py
@@ -3,6 +3,7 @@
# imports
#=============================================================================
# core
+from collections import OrderedDict
from functools import update_wrapper, wraps
import logging; log = logging.getLogger(__name__)
import sys
@@ -19,7 +20,7 @@ except ImportError:
from passlib import exc, registry
from passlib.context import CryptContext
from passlib.exc import PasslibRuntimeWarning
-from passlib.utils.compat import get_method_function, iteritems, OrderedDict, unicode
+from passlib.utils.compat import get_method_function
from passlib.utils.decor import memoized_property
# local
__all__ = [
@@ -180,7 +181,7 @@ class DjangoTranslator(object):
#=============================================================================
def __init__(self, context=None, **kwds):
- super(DjangoTranslator, self).__init__(**kwds)
+ super().__init__(**kwds)
if context is not None:
self.context = context
@@ -467,7 +468,7 @@ class DjangoContextAdapter(DjangoTranslator):
# init parent, filling in default context object
if context is None:
context = CryptContext()
- super(DjangoContextAdapter, self).__init__(context=context, **kwds)
+ super().__init__(context=context, **kwds)
# setup user category
if get_user_category:
@@ -504,7 +505,7 @@ class DjangoContextAdapter(DjangoTranslator):
reset_hashers(setting="PASSWORD_HASHERS")
# reset internal caches
- super(DjangoContextAdapter, self).reset_hashers()
+ super().reset_hashers()
#=============================================================================
# django hashers helpers -- hasher lookup
@@ -821,13 +822,7 @@ class DjangoContextAdapter(DjangoTranslator):
config = getattr(settings, "PASSLIB_CONTEXT", _UNSET)
if config is _UNSET:
config = "passlib-default"
- if config is None:
- warn("setting PASSLIB_CONFIG=None is deprecated, "
- "and support will be removed in Passlib 1.8, "
- "use PASSLIB_CONFIG='disabled' instead.",
- DeprecationWarning)
- config = "disabled"
- elif not isinstance(config, (unicode, bytes, dict)):
+ if not isinstance(config, (str, bytes, dict)):
raise exc.ExpectedTypeError(config, "str or dict", "PASSLIB_CONFIG")
# load custom category func (if any)
@@ -1001,7 +996,7 @@ class _PasslibHasherWrapper(object):
]
if hasattr(handler, "parsehash"):
kwds = handler.parsehash(encoded, sanitize=mask_hash)
- for key, value in iteritems(kwds):
+ for key, value in kwds.items():
key = self._translate_kwds.get(key, key)
items.append((_(key), value))
return OrderedDict(items)
@@ -1030,7 +1025,6 @@ class _PasslibHasherWrapper(object):
##from passlib.registry import register_crypt_handler
##from passlib.utils import classproperty, to_native_str, to_unicode
-##from passlib.utils.compat import unicode
##
##
##class _HasherHandler(object):
@@ -1068,7 +1062,7 @@ class _PasslibHasherWrapper(object):
## @property
## def ident(self):
## # this should always be correct, as django relies on ident prefix.
-## return unicode(self.django_name + "$")
+## return self.django_name + "$"
##
## @property
## def identify(self, hash):
@@ -1085,7 +1079,7 @@ class _PasslibHasherWrapper(object):
## opts['iterations'] = kwds.pop("rounds")
## if kwds:
## raise TypeError("unexpected keyword arguments: %r" % list(kwds))
-## if isinstance(secret, unicode):
+## if isinstance(secret, str):
## secret = secret.encode("utf-8")
## if salt is None:
## salt = self.django_hasher.salt()
@@ -1094,7 +1088,7 @@ class _PasslibHasherWrapper(object):
## @property
## def verify(self, secret, hash):
## hash = to_native_str(hash, "utf-8", "hash")
-## if isinstance(secret, unicode):
+## if isinstance(secret, str):
## secret = secret.encode("utf-8")
## return self.django_hasher.verify(secret, hash)
##
@@ -1168,7 +1162,7 @@ class _PatchManager(object):
def check_all(self, strict=False):
"""run sanity check on all keys, issue warning if out of sync"""
same = self._is_same_value
- for path, (orig, expected) in iteritems(self._state):
+ for path, (orig, expected) in self._state.items():
if same(self._get_path(path), expected):
continue
msg = "another library has patched resource: %r" % path
@@ -1222,7 +1216,7 @@ class _PatchManager(object):
##def patch_many(self, **kwds):
## "override specified resources with new values"
- ## for path, value in iteritems(kwds):
+ ## for path, value in kwds.items():
## self.patch(path, value)
def monkeypatch(self, parent, name=None, enable=True, wrap=False):