diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 14:49:50 -0400 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2020-10-06 14:49:50 -0400 |
commit | e82f75c13f9815f82b0cf046b2a502925f194703 (patch) | |
tree | 19e9bd2034b27e1fbcdfbfb93bfff29e6cbb848d /passlib/context.py | |
parent | 2cabd30db6306316c7a193585ea1cec5235d5209 (diff) | |
download | passlib-e82f75c13f9815f82b0cf046b2a502925f194703.tar.gz |
cleanup old python compat -- removed "unicode_or_str" and "native_string_types" aliases
Diffstat (limited to 'passlib/context.py')
-rw-r--r-- | passlib/context.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/passlib/context.py b/passlib/context.py index bafb4f4..6195d1b 100644 --- a/passlib/context.py +++ b/passlib/context.py @@ -21,7 +21,7 @@ from passlib.utils import (handlers as uh, to_bytes, from passlib.utils.binary import BASE64_CHARS from passlib.utils.compat import (num_types, unicode, - unicode_or_bytes_types, native_string_types, + unicode_or_bytes_types, ) from passlib.utils.decor import deprecated_method, memoized_property # local @@ -137,7 +137,7 @@ class _CryptConfig(object): """initialize .handlers and .schemes attributes""" handlers = [] schemes = [] - if isinstance(data, native_string_types): + if isinstance(data, str): data = splitcomma(data) for elem in data or (): # resolve elem -> handler & scheme @@ -145,7 +145,7 @@ class _CryptConfig(object): handler = elem scheme = handler.name _validate_handler_name(scheme) - elif isinstance(elem, native_string_types): + elif isinstance(elem, str): handler = get_crypt_handler(elem) scheme = handler.name else: @@ -248,7 +248,7 @@ class _CryptConfig(object): raise KeyError("%r option not allowed in CryptContext " "configuration" % (key,)) # coerce strings for certain fields (e.g. min_rounds uses ints) - if isinstance(value, native_string_types): + if isinstance(value, str): func = _coerce_scheme_options.get(key) if func: value = func(value) @@ -259,12 +259,12 @@ class _CryptConfig(object): if key == "default": if hasattr(value, "name"): value = value.name - elif not isinstance(value, native_string_types): + elif not isinstance(value, str): raise ExpectedTypeError(value, "str", "default") if schemes and value not in schemes: raise KeyError("default scheme not found in policy") elif key == "deprecated": - if isinstance(value, native_string_types): + if isinstance(value, str): value = splitcomma(value) elif not isinstance(value, (list,tuple)): raise ExpectedTypeError(value, "str or seq", "deprecated") @@ -277,7 +277,7 @@ class _CryptConfig(object): elif schemes: # make sure list of deprecated schemes is subset of configured schemes for scheme in value: - if not isinstance(scheme, native_string_types): + if not isinstance(scheme, str): raise ExpectedTypeError(value, "str", "deprecated element") if scheme not in schemes: raise KeyError("deprecated scheme not found " @@ -545,9 +545,9 @@ class _CryptConfig(object): pass # type check - if category is not None and not isinstance(category, native_string_types): + if category is not None and not isinstance(category, str): raise ExpectedTypeError(category, "str or None", "category") - if scheme is not None and not isinstance(scheme, native_string_types): + if scheme is not None and not isinstance(scheme, str): raise ExpectedTypeError(scheme, "str or None", "scheme") # if scheme=None, @@ -1014,7 +1014,7 @@ class CryptContext(object): def _parse_config_key(ckey): """helper used to parse ``cat__scheme__option`` keys into a tuple""" # split string into 1-3 parts - assert isinstance(ckey, native_string_types) + assert isinstance(ckey, str) parts = ckey.replace(".", "__").split("__") count = len(parts) if count == 1: @@ -1284,7 +1284,7 @@ class CryptContext(object): else: value = str(value) - assert isinstance(value, native_string_types), \ + assert isinstance(value, str), \ "expected string for key: %r %r" % (key, value) # escape any percent signs. |