mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106041)
[3.12] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)
These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt. They should not be
used in new code.
(cherry picked from commit 1d33d53780
)
This commit is contained in:
parent
746c0f3d8f
commit
9cd366462b
5 changed files with 35 additions and 34 deletions
|
@ -383,14 +383,15 @@ py_digest_by_digestmod(PyObject *module, PyObject *digestmod, enum Py_hash_type
|
|||
} else {
|
||||
_hashlibstate *state = get_hashlib_state(module);
|
||||
// borrowed ref
|
||||
name_obj = PyDict_GetItem(state->constructs, digestmod);
|
||||
name_obj = PyDict_GetItemWithError(state->constructs, digestmod);
|
||||
}
|
||||
if (name_obj == NULL) {
|
||||
_hashlibstate *state = get_hashlib_state(module);
|
||||
PyErr_Clear();
|
||||
PyErr_Format(
|
||||
state->unsupported_digestmod_error,
|
||||
"Unsupported digestmod %R", digestmod);
|
||||
if (!PyErr_Occurred()) {
|
||||
_hashlibstate *state = get_hashlib_state(module);
|
||||
PyErr_Format(
|
||||
state->unsupported_digestmod_error,
|
||||
"Unsupported digestmod %R", digestmod);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue