Improve _hashlib
exception reporting when an OpenSSL error occurred
#135234
Labels
_hashlib
exception reporting when an OpenSSL error occurred
#135234
Uh oh!
There was an error while loading. Please reload this page.
OpenSSL memory allocation failures
When an OpenSSL error occurs, we usually raise a
ValueError
. However, failures may be related tomalloc()
, in which case we should raise aMemoryError
as we usually do. I have a PR ready for this.Incorrect usage of
get_openssl_evp_md_by_utf8name()
In
get_openssl_evp_md_by_utf8name
, when we pass an incorrectPy_hash_type
or a digest that we cannot find, we raise:The "unsupported hash type %s" message only happens if no SSL error occurred during the execution, and this only happens if we pass an incorrect
Py_hash_type
, which also only happens "internally". So we should correctly report that the issue is with thePy_hash_type
argument, not with the named argument.Note: The
raise_ssl_error
function is a function that raises an automatically formatted message if there is an OpenSSL error or raises the "alternative" error message. But in this case, we should probably separate the exception and raise an SystemError / Py_UNREACHABLE() if we pass a wrongPy_hash_type
(strictly speaking, it shouldn't be possible because the compiler would have complained if we pass an arbitrary integer asPy_hash_type
is an enum).Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
This is related to the work I did in #134531.
Linked PRs
_hashlib
exceptions when reporting an OpenSSL function failure #135250The text was updated successfully, but these errors were encountered: