Skip to content

test_hashlib blake2 tests fail on python configured --without-builtin-hashlib-hashes #145028

@tucif

Description

@tucif

Bug report

Bug description:

Issue

test_hashlib fails on cpython configured --without-builtin-hashlib-hashes due to missing blake2 implementation.
The same happens if it was built with a subset of --with-builtin-hashlib-hashes that excludes blake2.

It seems that, because blake2 is not provided by the underlying openssl provider nor the builtin implementation due to configure flag, hashlib tests invoking exposed blake2* placeholders raise ValueError.

ERROR: test_algorithms_available (Lib.test.test_hashlib.HashLibTestCase.test_algorithms_available)
ERROR: test_blake2_update_over_4gb (Lib.test.test_hashlib.HashLibTestCase.test_blake2_update_over_4gb)
ERROR: test_clinic_signature (Lib.test.test_hashlib.HashLibTestCase.test_clinic_signature) [blake2s]
ERROR: test_clinic_signature (Lib.test.test_hashlib.HashLibTestCase.test_clinic_signature)
ERROR: test_clinic_signature_errors (Lib.test.test_hashlib.HashLibTestCase.test_clinic_signature_errors)
ERROR: test_copy (Lib.test.test_hashlib.HashLibTestCase.test_copy)
ERROR: test_gil (Lib.test.test_hashlib.HashLibTestCase.test_gil)
ERROR: test_hash_array (Lib.test.test_hashlib.HashLibTestCase.test_hash_array)
ERROR: test_hexdigest (Lib.test.test_hashlib.HashLibTestCase.test_hexdigest)
ERROR: test_large_update (Lib.test.test_hashlib.HashLibTestCase.test_large_update)
ERROR: test_name_attribute (Lib.test.test_hashlib.HashLibTestCase.test_name_attribute)
ERROR: test_threaded_hashing_fast (Lib.test.test_hashlib.HashLibTestCase.test_threaded_hashing_fast) [blake2s]
ERROR: test_threaded_hashing_slow (Lib.test.test_hashlib.HashLibTestCase.test_threaded_hashing_slow) [blake2s] (is_shake=False)
ERROR: test_threaded_hashing_slow (Lib.test.test_hashlib.HashLibTestCase.test_threaded_hashing_slow) [do_test_algorithm_via_hashlib_new_blake2s] (is_shake=False)
ERROR: test_threaded_hashing_slow (Lib.test.test_hashlib.HashLibTestCase.test_threaded_hashing_slow) [blake2b] (is_shake=False)
ERROR: test_threaded_hashing_slow (Lib.test.test_hashlib.HashLibTestCase.test_threaded_hashing_slow) [do_test_algorithm_via_hashlib_new_blake2b] (is_shake=False)
ERROR: test_usedforsecurity_false (Lib.test.test_hashlib.HashLibTestCase.test_usedforsecurity_false)
ERROR: test_usedforsecurity_true (Lib.test.test_hashlib.HashLibTestCase.test_usedforsecurity_true)

----------------------------------------------------------------------
Ran 82 tests in 7.012s

FAILED (errors=18, skipped=26)

Steps to reproduce

./configure --without-builtin-hashlib-hashes
make

# run isolated failure after make: 
./python -m unittest Lib.test.test_hashlib.HashLibTestCase

Suggested fix

I believe this to require a test-only fix.
test_hashlib already seems to have many guards for _blake2 module after conditional import checks.
It just seems there's a few more places that really assume blake2 variants are present, which may not be true.

I'm happy to provide a pull request for those changes.

CPython versions tested on:

CPython main branch, 3.14

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions