Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
OpenSSL memory allocation failures
When an OpenSSL error occurs, we usually raise aValueError. 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 ofget_openssl_evp_md_by_utf8name()
Inget_openssl_evp_md_by_utf8name, when we pass an incorrectPy_hash_type or a digest that we cannot find, we raise:
raise_ssl_error(state->unsupported_digestmod_error,"unsupported hash type %s",name);
The "unsupported hash type %s" message only happens if no SSL error occurred during the execution, and this only happens if we pass an incorrectPy_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: Theraise_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.