diff options
author | Guido van Rossum <guido@python.org> | 1992-09-04 09:45:18 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-09-04 09:45:18 (GMT) |
commit | 94472a0374f68fc7c746671eb87dc32253b02f05 (patch) | |
tree | 2771e08e0f6355403716eac5d9db818643f7d732 /Objects/moduleobject.c | |
parent | 9a4e3fc56a2bacc7af884117c53b37fdf104daa2 (diff) | |
download | cpython-94472a0374f68fc7c746671eb87dc32253b02f05.zip cpython-94472a0374f68fc7c746671eb87dc32253b02f05.tar.gz cpython-94472a0374f68fc7c746671eb87dc32253b02f05.tar.bz2 |
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
raise AttributeError, not KeyError, when attribute deletion fails.
sunaudiodevmodule.c: check for deletion before calling setmember.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r-- | Objects/moduleobject.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index bbe927c..aedba35 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -132,11 +132,16 @@ module_setattr(m, name, v) object *v; { if (strcmp(name, "__dict__") == 0 || strcmp(name, "__name__") == 0) { - err_setstr(TypeError, "can't assign to reserved member name"); + err_setstr(TypeError, "read-only special attribute"); return -1; } - if (v == NULL) - return dictremove(m->md_dict, name); + if (v == NULL) { + int rv = dictremove(m->md_dict, name); + if (rv < 0) + err_setstr(AttributeError, + "delete non-existing module attribute"); + return rv; + } else return dictinsert(m->md_dict, name, v); } |