]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.15] gh-110357: hashlib no longer logs at import when a guaranteed hash is unavaila...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Jun 2026 08:39:32 +0000 (10:39 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 08:39:32 +0000 (08:39 +0000)
commitaf665032a599d84edf87457435059393ec38779a
treea54ec2c587400ba4c1414281e2703f4bd65c0868
parent4f140148c45214dd43ebcd6546ed5799521b536b
[3.15] gh-110357: hashlib no longer logs at import when a guaranteed hash is unavailable (GH-152538) (#152554)

gh-110357: hashlib no longer logs at import when a guaranteed hash is unavailable (GH-152538)

When a normally-guaranteed hash algorithm cannot be constructed at import time
(e.g. an OpenSSL FIPS configuration excludes it from the default provider, or
the build used --without-builtin-hashlib-hashes), importing hashlib emitted an
"ERROR:root:hash algorithm ... will not be supported at runtime" message to
stderr.  For the many programs that never use the missing algorithm this is
pure noise.  Worse, logging.error() lazily calls logging.basicConfig(), which
mutates the root logger's handlers -- a global side effect that the test suite
flags as an altered execution environment.

Stop logging in that path.  Code that actually uses a missing algorithm still
gets a clear ValueError from the stub constructor installed in its place.

The stray output has shown up incidentally in FIPS / "No Builtin Hashes"
buildbot reports for years (e.g. gh-110357, gh-76902) without being the
reported subject.
(cherry picked from commit 8ae1a236fd334a590e90028f615cd4a822ae6f97)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Doc/library/hashlib.rst
Lib/hashlib.py
Misc/NEWS.d/next/Library/2026-06-29-01-08-53.gh-issue-110357.QGWdZQ.rst [new file with mode: 0644]