mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -133,8 +133,13 @@ class_setattr(op, name, v)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (v == NULL)
|
||||
return dictremove(op->cl_methods, name);
|
||||
if (v == NULL) {
|
||||
int rv = dictremove(op->cl_methods, name);
|
||||
if (rv < 0)
|
||||
err_setstr(AttributeError,
|
||||
"delete non-existing class attribute");
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return dictinsert(op->cl_methods, name, v);
|
||||
}
|
||||
|
@ -245,8 +250,13 @@ instance_setattr(inst, name, v)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (v == NULL)
|
||||
return dictremove(inst->in_attr, name);
|
||||
if (v == NULL) {
|
||||
int rv = dictremove(inst->in_attr, name);
|
||||
if (rv < 0)
|
||||
err_setstr(AttributeError,
|
||||
"delete non-existing instance attribute");
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return dictinsert(inst->in_attr, name, v);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue