Use new exceptions.
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index e996ac8..03e2db5 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -68,6 +68,8 @@
 
 #include "stdwin.h"
 
+#define StdwinError RuntimeError /* XXX Change this later */
+
 /* Window and menu object types declared here because of forward references */
 
 typedef struct {
@@ -870,7 +872,7 @@
 	if (!getrectarg(args, a))
 		return NULL;
 	if (Drawing != NULL) {
-		err_setstr(RuntimeError, "already drawing");
+		err_setstr(StdwinError, "already drawing");
 		return NULL;
 	}
 	/* Clip to text area and ignore if area is empty */
@@ -1029,8 +1031,7 @@
 		return NULL;
 	size = getstringsize(text);
 	if ((buf = NEW(char, size)) == NULL) {
-		err_set(MemoryError);
-		return NULL;
+		return err_nomem();
 	}
 	memcpy(buf, getstringvalue(text), size);
 	tesetbuf(self->t_text, buf, size); /* Becomes owner of buffer */
@@ -1145,7 +1146,7 @@
 			break;
 	}
 	if (id >= MAXNMENU) {
-		err_setstr(MemoryError, "creating too many menus");
+		err_setstr(StdwinError, "creating too many menus");
 		return NULL;
 	}
 	menu = wmenucreate(id + IDOFFSET, getstringvalue(title));
@@ -1374,7 +1375,7 @@
 	if (!getnoarg(args))
 		return NULL;
 	if (Drawing != NULL) {
-		err_setstr(RuntimeError, "already drawing");
+		err_setstr(StdwinError, "already drawing");
 		return NULL;
 	}
 	dp = NEWOBJ(drawingobject, &Drawingtype);
@@ -1596,7 +1597,7 @@
 		return NULL;
 	c = wfetchcursor(getstringvalue(str));
 	if (c == NULL) {
-		err_setstr(RuntimeError, "no such cursor");
+		err_setstr(StdwinError, "no such cursor");
 		return NULL;
 	}
 	wsetwincursor(self->w_win, c);
@@ -1710,7 +1711,7 @@
 			break;
 	}
 	if (tag >= MAXNWIN) {
-		err_setstr(MemoryError, "creating too many windows");
+		err_setstr(StdwinError, "creating too many windows");
 		return NULL;
 	}
 	wp = NEWOBJ(windowobject, &Windowtype);
@@ -1766,7 +1767,7 @@
 	if (!getnoarg(args))
 		return NULL;
 	if (Drawing != NULL) {
-		err_setstr(RuntimeError, "cannot getevent() while drawing");
+		err_setstr(StdwinError, "cannot getevent() while drawing");
 		return NULL;
 	}
  again:
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index b25615933..1f1dcae 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -95,7 +95,7 @@
 #endif
 	f->f_fp = fopen(name, mode);
 	if (f->f_fp == NULL) {
-		err_errno(RuntimeError);
+		err_errno(IOError);
 		DECREF(f);
 		return NULL;
 	}
@@ -166,7 +166,7 @@
 	if (sts == EOF) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	if (sts != 0)
 		return newintobject((long)sts);
@@ -198,7 +198,7 @@
 	if (fseek(f->f_fp, offset, (int)whence) != 0) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	INCREF(None);
 	return None;
@@ -219,7 +219,7 @@
 	if (offset == -1L) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	return newintobject(offset);
 }
@@ -237,7 +237,7 @@
 	if (fflush(f->f_fp) != 0) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	INCREF(None);
 	return None;
@@ -441,7 +441,6 @@
 	object *args;
 {
 	int n, n2;
-	char *s;
 	if (f->f_fp == NULL) {
 		err_badarg();
 		return NULL;
@@ -452,20 +451,11 @@
 	}
 	f->f_softspace = 0;
 	errno = 0;
-	n = getstringsize(args);
-	s = getstringvalue(args);
-	if (n > BUFSIZ) {
-		fflush(f->f_fp);
-		n2 = write(fileno(f->f_fp), s, n);
-		fflush(f->f_fp);
-	}
-	else {
-		n2 = fwrite(s, 1, n, f->f_fp);
-	}
+	n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp);
 	if (n2 != n) {
 		if (errno == 0)
 			errno = EIO;
-		err_errno(RuntimeError);
+		err_errno(IOError);
 		return NULL;
 	}
 	INCREF(None);
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 18bdbca..2e2b9a2 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -543,7 +543,7 @@
 		if (cmpobject(self->ob_item[i], args) == 0)
 			return newintobject(i);
 	}
-	err_setstr(RuntimeError, "list.index(x): x not in list");
+	err_setstr(ValueError, "list.index(x): x not in list");
 	return NULL;
 }
 
@@ -586,7 +586,7 @@
 		}
 			
 	}
-	err_setstr(RuntimeError, "list.remove(x): x not in list");
+	err_setstr(ValueError, "list.remove(x): x not in list");
 	return NULL;
 }
 
diff --git a/Objects/longobject.c b/Objects/longobject.c
index fb5d241..37f2f35 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -168,7 +168,7 @@
 		prev = x;
 		x = (x << SHIFT) + v->ob_digit[i];
 		if ((x >> SHIFT) != prev) {
-			err_setstr(RuntimeError,
+			err_setstr(ValueError,
 				"long int too long to convert");
 			return -1;
 		}
@@ -422,7 +422,7 @@
 	if (size_b == 0) {
 		if (prem != NULL)
 			*prem = NULL;
-		err_setstr(RuntimeError, "long division by zero");
+		err_setstr(ZeroDivisionError, "long division or remainder");
 		return NULL;
 	}
 	if (size_a < size_b ||
@@ -938,7 +938,7 @@
 	if (size_b == ~0)
 		size_b = 0;
 	else if (size_b < 0) {
-		err_setstr(RuntimeError, "long integer to the negative power");
+		err_setstr(ValueError, "long integer to the negative power");
 		return NULL;
 	}
 
@@ -1054,11 +1054,11 @@
 	if (shiftby == -1L && err_occurred())
 		return NULL;
 	if (shiftby < 0) {
-		err_setstr(RuntimeError, "negative shift count");
+		err_setstr(ValueError, "negative shift count");
 		return NULL;
 	}
 	if (shiftby > MASK) {
-		err_setstr(RuntimeError, "outrageous shift count");
+		err_setstr(ValueError, "outrageous shift count");
 		return NULL;
 	}
 	wordshift = shiftby / SHIFT;
@@ -1105,11 +1105,11 @@
 	if (shiftby == -1L && err_occurred())
 		return NULL;
 	if (shiftby < 0) {
-		err_setstr(RuntimeError, "negative shift count");
+		err_setstr(ValueError, "negative shift count");
 		return NULL;
 	}
 	if (shiftby > MASK) {
-		err_setstr(RuntimeError, "outrageous shift count");
+		err_setstr(ValueError, "outrageous shift count");
 		return NULL;
 	}
 	if (shiftby % SHIFT == 0) {
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index ffc8e74..1104986 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -118,7 +118,7 @@
 	}
 	res = dictlookup(m->md_dict, name);
 	if (res == NULL)
-		err_setstr(NameError, name);
+		err_setstr(AttributeError, name);
 	else
 		INCREF(res);
 	return res;
@@ -131,7 +131,7 @@
 	object *v;
 {
 	if (strcmp(name, "__dict__") == 0 || strcmp(name, "__name__") == 0) {
-		err_setstr(NameError, "can't assign to reserved member name");
+		err_setstr(TypeError, "can't assign to reserved member name");
 		return -1;
 	}
 	if (v == NULL)
diff --git a/Python/errors.c b/Python/errors.c
index 70a85ba..3b7d4a1 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -180,10 +180,10 @@
 	case E_OK:
 		break;
 	case E_SYNTAX:
-		err_setstr(RuntimeError, "syntax error");
+		err_setstr(ValueError, "syntax error");
 		break;
 	case E_TOKEN:
-		err_setstr(RuntimeError, "illegal token");
+		err_setstr(ValueError, "illegal token");
 		break;
 	case E_INTR:
 		err_set(KeyboardInterrupt);
@@ -195,7 +195,7 @@
 		err_set(EOFError);
 		break;
 	default:
-		err_setstr(RuntimeError, "unknown input error");
+		err_setstr(SystemError, "unknown input error");
 		break;
 	}
 }
diff --git a/Python/marshal.c b/Python/marshal.c
index 1af49eb..d065ebe 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -191,7 +191,7 @@
 	switch (type) {
 	
 	case EOF:
-		err_setstr(RuntimeError, "EOF read where object expected");
+		err_setstr(EOFError, "EOF read where object expected");
 		return NULL;
 	
 	case TYPE_NULL:
@@ -227,7 +227,7 @@
 			char *end;
 			n = rd_byte(fp);
 			if (fread(buf, 1, (int)n, fp) != n) {
-				err_setstr(RuntimeError,
+				err_setstr(EOFError,
 					"EOF read where object expected");
 				return NULL;
 			}
@@ -235,11 +235,11 @@
 			errno = 0;
 			res = strtod(buf, &end);
 			if (*end != '\0') {
-				err_setstr(RuntimeError, "bad float syntax");
+				err_setstr(ValueError, "bad float syntax");
 				return NULL;
 			}
 			if (errno != 0) {
-				err_setstr(RuntimeError,
+				err_setstr(ValueError,
 					"float constant too large");
 				return NULL;
 			}
@@ -253,7 +253,7 @@
 			if (fread(getstringvalue(v), 1, (int)n, fp) != n) {
 				DECREF(v);
 				v = NULL;
-				err_setstr(RuntimeError,
+				err_setstr(EOFError,
 					"EOF read where object expected");
 			}
 		}
@@ -314,7 +314,7 @@
 		return v;
 	
 	default:
-		err_setstr(RuntimeError, "read unknown object");
+		err_setstr(TypeError, "read unknown object");
 		return NULL;
 	
 	}
diff --git a/Python/structmember.c b/Python/structmember.c
index acdf9c6..bd04e7c 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -103,7 +103,7 @@
 		}
 	}
 	
-	err_setstr(NameError, name);
+	err_setstr(AttributeError, name);
 	return NULL;
 }
 
@@ -119,7 +119,7 @@
 	for (l = mlist; l->name != NULL; l++) {
 		if (strcmp(l->name, name) == 0) {
 			if (l->readonly || l->type == T_STRING) {
-				err_setstr(RuntimeError, "readonly attribute");
+				err_setstr(TypeError, "readonly attribute");
 				return -1;
 			}
 			addr += l->offset;
@@ -178,6 +178,6 @@
 		}
 	}
 	
-	err_setstr(NameError, name);
+	err_setstr(AttributeError, name);
 	return -1;
 }