Skip to content

Commit c51d22f

Browse files
committed
keep logging verbosity
1 parent 2720b6b commit c51d22f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Lib/hashlib.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,16 @@ def file_digest(fileobj, digest, /, *, _bufsize=2**18):
261261
return digestobj
262262

263263

264-
__logger = __logging = None
264+
__logging = None
265265
for __func_name in __always_supported:
266266
# try them all, some may not work due to the OpenSSL
267267
# version not supporting that algorithm.
268268
try:
269269
globals()[__func_name] = __get_hash(__func_name)
270-
except ValueError:
270+
except ValueError as __exc:
271271
import logging as __logging
272-
if __logger is None:
273-
__logger = __logging.getLogger(__name__)
274-
__logger.warning('hash algorithm %s will not be supported at runtime',
275-
__func_name)
272+
__logging.error('hash algorithm %s will not be supported at runtime '
273+
'[reason: %s]', __func_name, __exc)
276274
# The following code can be simplified in Python 3.19
277275
# once "string" is removed from the signature.
278276
__code = f'''\
@@ -293,9 +291,9 @@ def {__func_name}(data=__UNSET, *, usedforsecurity=True, string=__UNSET):
293291
'''
294292
exec(__code, {"__UNSET": object()}, __locals := {})
295293
globals()[__func_name] = __locals[__func_name]
296-
del __code, __locals
294+
del __exc, __code, __locals
297295

298296
# Cleanup locals()
299297
del __always_supported, __func_name, __get_hash
300298
del __py_new, __hash_new, __get_openssl_constructor
301-
del __logger, __logging
299+
del __logging

0 commit comments

Comments
 (0)