mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.
This commit is contained in:
parent
41ad4dfc04
commit
1d33d53780
5 changed files with 35 additions and 34 deletions
|
@ -1508,11 +1508,14 @@ type_set_annotations(PyTypeObject *type, PyObject *value, void *context)
|
|||
static PyObject *
|
||||
type_get_type_params(PyTypeObject *type, void *context)
|
||||
{
|
||||
PyObject *params = PyDict_GetItem(lookup_tp_dict(type), &_Py_ID(__type_params__));
|
||||
PyObject *params = PyDict_GetItemWithError(lookup_tp_dict(type), &_Py_ID(__type_params__));
|
||||
|
||||
if (params) {
|
||||
return Py_NewRef(params);
|
||||
}
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue