mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
raise AttributeError, not KeyError, when attribute deletion fails. sunaudiodevmodule.c: check for deletion before calling setmember.
This commit is contained in:
parent
9a4e3fc56a
commit
94472a0374
5 changed files with 56 additions and 15 deletions
|
@ -1051,8 +1051,13 @@ text_setattr(tp, name, v)
|
|||
if (tp->t_attr == NULL)
|
||||
return -1;
|
||||
}
|
||||
if (v == NULL)
|
||||
return dictremove(tp->t_attr, name);
|
||||
if (v == NULL) {
|
||||
int rv = dictremove(tp->t_attr, name);
|
||||
if (rv < 0)
|
||||
err_setstr(AttributeError,
|
||||
"delete non-existing text object attribute");
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return dictinsert(tp->t_attr, name, v);
|
||||
}
|
||||
|
@ -1253,8 +1258,13 @@ menu_setattr(mp, name, v)
|
|||
if (mp->m_attr == NULL)
|
||||
return -1;
|
||||
}
|
||||
if (v == NULL)
|
||||
return dictremove(mp->m_attr, name);
|
||||
if (v == NULL) {
|
||||
int rv = dictremove(mp->m_attr, name);
|
||||
if (rv < 0)
|
||||
err_setstr(AttributeError,
|
||||
"delete non-existing menu object attribute");
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return dictinsert(mp->m_attr, name, v);
|
||||
}
|
||||
|
@ -1655,8 +1665,13 @@ window_setattr(wp, name, v)
|
|||
if (wp->w_attr == NULL)
|
||||
return -1;
|
||||
}
|
||||
if (v == NULL)
|
||||
return dictremove(wp->w_attr, name);
|
||||
if (v == NULL) {
|
||||
int rv = dictremove(wp->w_attr, name);
|
||||
if (rv < 0)
|
||||
err_setstr(AttributeError,
|
||||
"delete non-existing menu object attribute");
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return dictinsert(wp->w_attr, name, v);
|
||||
}
|
||||
|
|
|
@ -343,6 +343,12 @@ sads_setattr(xp, name, v)
|
|||
char *name;
|
||||
object *v;
|
||||
{
|
||||
|
||||
if (v == NULL) {
|
||||
err_setstr(TypeError,
|
||||
"can't delete sun audio status attributes");
|
||||
return NULL;
|
||||
}
|
||||
return setmember((char *)&xp->ai, sads_ml, name, v);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue