diff options
| -rw-r--r-- | docs/history/1.7.rst | 3 | ||||
| -rw-r--r-- | passlib/utils/__init__.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/docs/history/1.7.rst b/docs/history/1.7.rst index ad181f9..096f7ed 100644 --- a/docs/history/1.7.rst +++ b/docs/history/1.7.rst @@ -4,6 +4,9 @@ Passlib 1.7 =========== +* :func:`passlib.utils.safe_crypt`: Support :func:`crypt.crypt` unexpectedly + returning bytes under Python 3 (:issue:`113`). + **1.7.2** (2019-11-22) ====================== diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index e08c12f..1994fe6 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -792,6 +792,11 @@ else: if isinstance(hash, bytes): hash = hash.decode("ascii") result = _crypt(secret, hash) + # NOTE: per issue 113, crypt() may return bytes in some odd cases. + # assuming it should still return an ASCII hash though, + # or there's a bigger issue at hand. + if isinstance(result, bytes): + result = result.decode("ascii") if not result or result[0] in _invalid_prefixes: return None return result |
