Index: generic/tclEvent.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclEvent.c,v
retrieving revision 1.78
diff -u -r1.78 tclEvent.c
--- generic/tclEvent.c	13 Dec 2007 15:23:16 -0000	1.78
+++ generic/tclEvent.c	25 Feb 2008 02:47:13 -0000
@@ -309,7 +309,7 @@
 {
     Tcl_Obj *keyPtr, *valuePtr;
     Tcl_Obj *tempObjv[2];
-    int code, level;
+    int code, level, rc;
     Tcl_InterpState saved;
 
     if (objc != 3) {
@@ -328,18 +328,28 @@
 
     TclNewLiteralStringObj(keyPtr, "-level");
     Tcl_IncrRefCount(keyPtr);
-    Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
+    rc = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
     Tcl_DecrRefCount(keyPtr);
-    Tcl_GetIntFromObj(NULL, valuePtr, &level);
+    if (rc == TCL_OK && valuePtr != NULL) {
+        Tcl_GetIntFromObj(NULL, valuePtr, &level);
+    } else {
+        /* Default to level 0 */
+        level = 0;
+    }
     if (level != 0) {
 	/* We're handling a TCL_RETURN exception */
 	code = TCL_RETURN;
     } else {
 	TclNewLiteralStringObj(keyPtr, "-code");
 	Tcl_IncrRefCount(keyPtr);
-	Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
+	rc = Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
 	Tcl_DecrRefCount(keyPtr);
-	Tcl_GetIntFromObj(NULL, valuePtr, &code);
+        if (rc == TCL_OK && valuePtr != NULL) {
+            Tcl_GetIntFromObj(NULL, valuePtr, &code);
+        } else {
+            /* Assume error code */
+            code = TCL_ERROR;
+        }
     }
     switch (code) {
     case TCL_ERROR:
