mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
bpo-41991: Remove _PyObject_HasAttrId (GH-22629)
It can silence arbitrary exceptions.
This commit is contained in:
parent
02a1603f91
commit
98c4433a81
5 changed files with 28 additions and 22 deletions
|
|
@ -311,21 +311,22 @@ union_repr_item(_PyUnicodeWriter *writer, PyObject *p)
|
|||
_Py_IDENTIFIER(__args__);
|
||||
PyObject *qualname = NULL;
|
||||
PyObject *module = NULL;
|
||||
PyObject *tmp;
|
||||
PyObject *r = NULL;
|
||||
int err;
|
||||
|
||||
int has_origin = _PyObject_HasAttrId(p, &PyId___origin__);
|
||||
if (has_origin < 0) {
|
||||
if (_PyObject_LookupAttrId(p, &PyId___origin__, &tmp) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (has_origin) {
|
||||
int has_args = _PyObject_HasAttrId(p, &PyId___args__);
|
||||
if (has_args < 0) {
|
||||
if (tmp) {
|
||||
Py_DECREF(tmp);
|
||||
if (_PyObject_LookupAttrId(p, &PyId___args__, &tmp) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (has_args) {
|
||||
if (tmp) {
|
||||
// It looks like a GenericAlias
|
||||
Py_DECREF(tmp);
|
||||
goto use_repr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue