diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2019-11-11 10:45:44 -0500 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2019-11-11 10:45:44 -0500 |
| commit | e13c7c25b7145b5ef3fa0e7a424f46ab02a106c4 (patch) | |
| tree | 122952c68591a3b4a61e6bc875c839daa7f8cf79 /passlib/handlers | |
| parent | a945d60e814337e668c647a043bfd6adcbd9d47e (diff) | |
| download | passlib-e13c7c25b7145b5ef3fa0e7a424f46ab02a106c4.tar.gz | |
bcrypt: py2 compat fix -- add compat wrapper for edge case in pybcrypt detection code;
along with some other notes
Diffstat (limited to 'passlib/handlers')
| -rw-r--r-- | passlib/handlers/bcrypt.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/passlib/handlers/bcrypt.py b/passlib/handlers/bcrypt.py index e5fbfe0..222c5ce 100644 --- a/passlib/handlers/bcrypt.py +++ b/passlib/handlers/bcrypt.py @@ -28,6 +28,7 @@ from passlib.exc import PasslibHashWarning, PasslibSecurityWarning, PasslibSecur from passlib.utils import safe_crypt, repeat_string, to_bytes, parse_version, \ rng, getrandstr, test_crypt, to_unicode from passlib.utils.binary import bcrypt64 +from passlib.utils.compat import get_unbound_method_function from passlib.utils.compat import u, uascii_to_str, unicode, str_to_uascii import passlib.utils.handlers as uh @@ -72,6 +73,8 @@ def _detect_pybcrypt(): try: import bcrypt except ImportError: + # XXX: this is ignoring case where py-bcrypt's "bcrypt._bcrypt" C Ext fails to import; + # would need to inspect actual ImportError message to catch that. return None # py-bcrypt has a "._bcrypt.__version__" attribute (confirmed for v0.1 - 0.4), @@ -647,6 +650,7 @@ class _PyBcryptBackend(_BcryptCommon): try: import bcrypt as _pybcrypt except ImportError: # pragma: no cover + # XXX: should we raise AssertionError here? (if get here, _detect_pybcrypt() is broken) return False # determine pybcrypt version @@ -666,7 +670,7 @@ class _PyBcryptBackend(_BcryptCommon): if mixin_cls._calc_lock is None: import threading mixin_cls._calc_lock = threading.Lock() - mixin_cls._calc_checksum = mixin_cls._calc_checksum_threadsafe.__func__ + mixin_cls._calc_checksum = get_unbound_method_function(mixin_cls._calc_checksum_threadsafe) return mixin_cls._finalize_backend_mixin(name, dryrun) |
