mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106040)
[3.11] 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
c69f29f879
commit
dbe416b82b
3 changed files with 30 additions and 32 deletions
|
@ -1138,15 +1138,13 @@ print_exception_notes(struct exception_print_context *ctx, PyObject *value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!PyObject_HasAttr(value, &_Py_ID(__notes__))) {
|
||||
return 0;
|
||||
}
|
||||
PyObject *notes = PyObject_GetAttr(value, &_Py_ID(__notes__));
|
||||
if (notes == NULL) {
|
||||
return -1;
|
||||
PyObject *notes;
|
||||
int res = _PyObject_LookupAttr(value, &_Py_ID(__notes__), ¬es);
|
||||
if (res <= 0) {
|
||||
return res;
|
||||
}
|
||||
if (!PySequence_Check(notes)) {
|
||||
int res = 0;
|
||||
res = 0;
|
||||
if (write_indented_margin(ctx, f) < 0) {
|
||||
res = -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue