summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/contrib/auth/hashers.py1
-rw-r--r--tests/auth_tests/test_hashers.py4
2 files changed, 5 insertions, 0 deletions
diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 7658379871..6cd57f197a 100644
--- a/django/contrib/auth/hashers.py
+++ b/django/contrib/auth/hashers.py
@@ -602,6 +602,7 @@ class CryptPasswordHasher(BasePasswordHasher):
crypt = self._load_library()
assert len(salt) == 2
data = crypt.crypt(force_str(password), salt)
+ assert data is not None # A platform like OpenBSD with a dummy crypt module.
# we don't need to store the salt, but Django used to do this
return "%s$%s$%s" % (self.algorithm, '', data)
diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py
index a43c170ec1..845deee646 100644
--- a/tests/auth_tests/test_hashers.py
+++ b/tests/auth_tests/test_hashers.py
@@ -19,6 +19,10 @@ try:
import crypt
except ImportError:
crypt = None
+else:
+ # On some platforms (e.g. OpenBSD), crypt.crypt() always return None.
+ if crypt.crypt('', '') is None:
+ crypt = None
try:
import bcrypt