Skip to content

Comments

gh-145028: Fix blake2 tests in test_hashlib when it is missing due to configure --without-builtin-hashlib-hashes#145029

Merged
gpshead merged 5 commits intopython:mainfrom
tucif:tucif/without_blake2
Feb 21, 2026
Merged

gh-145028: Fix blake2 tests in test_hashlib when it is missing due to configure --without-builtin-hashlib-hashes#145029
gpshead merged 5 commits intopython:mainfrom
tucif:tucif/without_blake2

Conversation

@tucif
Copy link
Contributor

@tucif tucif commented Feb 20, 2026

This PR addresses Issue #145028 tracking test_hashlib failure on cpython configured --without-builtin-hashlib-hashes

Changes in test_hashlib.py

  • Guard testing of blake2 with existing utils to verify its existence (@require_blake2)
  • Remove blake2 variations from algorithms in constructor when _blake2 is None, as they may already be in that list through its initialization from self.supported_hashnames.
  • Add subtests in test_algorithms_available and skip if ValueError is raised, so it's easy to tell what exactly was skipped and why.
  • Add skip_if_blake2_not_builtin helper

Testing with fix on python without builtin blake2

python -m unittest Lib.test.test_hashlib.HashLibTestCase
...
----------------------------------------------------------------------
Ran 82 tests in 7.005s

OK (skipped=29)

Sample skips on test_algorithms_available

  test_algorithms_available (Lib.test.test_hashlib.HashLibTestCase.test_algorithms_available) [blake2b] ... skipped 'unsupported hash algorithm blake2b'
  test_algorithms_available (Lib.test.test_hashlib.HashLibTestCase.test_algorithms_available) [blake2s] ... skipped 'unsupported hash algorithm blake2s'

…_algorithms_available if implementation is not provided
@python-cla-bot
Copy link

python-cla-bot bot commented Feb 20, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Feb 20, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

- Moved retrieval of PY_BUILTIN_HASHLIB_HASHES out of the loop
- Removed guard from test_gil
- Remove assert for None as that is not a possible return value anyway
- Renamed verr to exc
- Renamed digest to _ as it is ignored
@gpshead gpshead added the needs backport to 3.14 bugs and security fixes label Feb 21, 2026
@gpshead gpshead merged commit 273d506 into python:main Feb 21, 2026
51 checks passed
@miss-islington-app
Copy link

Thanks @tucif for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @tucif and @gpshead, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 273d5062ca17ac47354486f3fc6e672a04cf22e0 3.14

@gpshead gpshead removed the needs backport to 3.14 bugs and security fixes label Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants