diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2019-11-19 14:41:26 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2019-11-19 14:41:26 -0500 |
commit | 5a1a6a1ba7c637462c25d307c5ef7a7777f51d57 (patch) | |
tree | 82f851eaf8162cd4589dd49f42951231623caf64 | |
parent | 9ce79edd8965d027a35835de9c31010d509d8ad0 (diff) | |
download | passlib-5a1a6a1ba7c637462c25d307c5ef7a7777f51d57.tar.gz |
bugfix: argon2: replace directive with equivalent that will work under py26/33/34
(dict comprehensions and b"" % format directives both cause issues)
-rw-r--r-- | passlib/handlers/argon2.py | 5 | ||||
-rw-r--r-- | passlib/utils/__init__.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/passlib/handlers/argon2.py b/passlib/handlers/argon2.py index 2ac4b1b..4a5691b 100644 --- a/passlib/handlers/argon2.py +++ b/passlib/handlers/argon2.py @@ -28,7 +28,7 @@ _argon2pure = None # dynamically imported by _load_backend_argon2pure() # pkg from passlib import exc from passlib.crypto.digest import MAX_UINT32 -from passlib.utils import classproperty, to_bytes +from passlib.utils import classproperty, to_bytes, render_bytes from passlib.utils.binary import b64s_encode, b64s_decode from passlib.utils.compat import u, unicode, bascii_to_str, uascii_to_str, PY2 import passlib.utils.handlers as uh @@ -753,7 +753,8 @@ class _CffiBackend(_Argon2Common): raise cls._adapt_backend_error(err) #: helper for verify() method below -- maps prefixes to type constants - _byte_ident_map = {b"$argon2%s$" % type.encode("ascii"): type for type in ALL_TYPES} + _byte_ident_map = dict((render_bytes(b"$argon2%s$", type.encode("ascii")), type) + for type in ALL_TYPES) @classmethod def verify(cls, secret, hash): diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index 880401e..e08c12f 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -541,6 +541,10 @@ def render_bytes(source, *args): Calling ``render_bytes(source, *args)`` should function roughly the same as ``source % args`` under Python 2. + + .. todo:: + python >= 3.5 added back limited support for bytes %, + can revisit when 3.3/3.4 is dropped. """ if isinstance(source, bytes): source = source.decode("latin-1") |