Mercurial > cpython-lru_cache-weakref
diff Objects/moduleobject.c @ 1031:7a11a70f7f44 legacy-trunk
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
raise AttributeError, not KeyError, when attribute deletion fails.
sunaudiodevmodule.c: check for deletion before calling setmember.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 04 Sep 1992 09:45:18 +0000 |
| parents | 0cd197947d81 |
| children | f54e64c8b9b7 |
line wrap: on
line diff
--- a/Objects/moduleobject.c Thu Sep 03 21:27:55 1992 +0000 +++ b/Objects/moduleobject.c Fri Sep 04 09:45:18 1992 +0000 @@ -132,11 +132,16 @@ 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); }
