Warning about missing `bcrypt.__about__`, after upgrading bcrypt from 4.0.1 to 4.1.1
When upgrading the bcrypt
dependency from 4.0.1 to 4.1.1 (note that 4.1.0 was yanked), the bcrypt.__about__.__version__
attribute is not available any more, while bcrypt.__version__
remains. See following test with python 3.10.12, on Ubuntu 22.04.3:
$ pip install bcrypt==4.0.1
Collecting bcrypt==4.0.1
Using cached bcrypt-4.0.1-cp36-abi3-manylinux_2_28_x86_64.whl (593 kB)
Installing collected packages: bcrypt
Attempting uninstall: bcrypt
Found existing installation: bcrypt 4.1.1
Uninstalling bcrypt-4.1.1:
Successfully uninstalled bcrypt-4.1.1
Successfully installed bcrypt-4.0.1
$ python -c "import bcrypt; print(bcrypt.__about__.__version__)"
4.0.1
$ python -c "import bcrypt; print(bcrypt.__version__)"
4.0.1
$ pip install bcrypt==4.1.1
Collecting bcrypt==4.1.1
Using cached bcrypt-4.1.1-cp37-abi3-manylinux_2_28_x86_64.whl (699 kB)
Installing collected packages: bcrypt
Attempting uninstall: bcrypt
Found existing installation: bcrypt 4.0.1
Uninstalling bcrypt-4.0.1:
Successfully uninstalled bcrypt-4.0.1
Successfully installed bcrypt-4.1.1
$ python -c "import bcrypt; print(bcrypt.__about__.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'bcrypt' has no attribute '__about__'
$ python -c "import bcrypt; print(bcrypt.__version__)"
4.1.1
passlib
tries to access the __about__.__version__
attribute in the following block in handlers/bcrypt.py
(ref https://foss.heptapod.net/python-libs/passlib/-/blob/branch/stable/passlib/handlers/bcrypt.py):
try:
version = _bcrypt.__about__.__version__
except:
log.warning("(trapped) error reading bcrypt version", exc_info=True)
version = '<unknown>'
and then raises a warning:
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from passlib.hash import bcrypt
>>> h = bcrypt.hash("password")
(trapped) error reading bcrypt version
Traceback (most recent call last):
File "/home/tommaso/Fractal/fractal-server/tests/data/example_server_startup/venv/lib/python3.10/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
version = _bcrypt.__about__.__version__
AttributeError: module 'bcrypt' has no attribute '__about__'
EDIT: here is the relevant bcrypt commit: https://github.com/pyca/bcrypt/commit/7939bef883a6ede5691134a250087c066e371bc0
Edited by Tommaso Comparin