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:
Guido van Rossum 1992-09-04 09:45:18 +00:00
parent 9a4e3fc56a
commit 94472a0374
5 changed files with 56 additions and 15 deletions

View file

@ -110,8 +110,13 @@ xx_setattr(xp, name, v)
if (xp->x_attr == NULL)
return -1;
}
if (v == NULL)
return dictremove(xp->x_attr, name);
if (v == NULL) {
int rv = dictremove(xp->x_attr, name);
if (rv < 0)
err_setstr(AttributeError,
"delete non-existing xx attribute");
return rv;
}
else
return dictinsert(xp->x_attr, name, v);
}