diff Modules/stdwinmodule.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 c156d4960c2b
children f54e64c8b9b7
line wrap: on
line diff
--- a/Modules/stdwinmodule.c	Thu Sep 03 21:27:55 1992 +0000
+++ b/Modules/stdwinmodule.c	Fri Sep 04 09:45:18 1992 +0000
@@ -1051,8 +1051,13 @@
 		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 @@
 		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 @@
 		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);
 }