Index: generic/tclVar.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclVar.c,v
retrieving revision 1.176
diff -u -r1.176 tclVar.c
--- generic/tclVar.c	10 Feb 2009 23:08:57 -0000	1.176
+++ generic/tclVar.c	18 Mar 2009 16:37:24 -0000
@@ -972,13 +972,9 @@
 			flags, &varNsPtr, &dummy1Ptr, &dummy2Ptr, &tail);
 		if (varNsPtr == NULL) {
 		    *errMsgPtr = badNamespace;
-		    Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME",
-			    NULL);
 		    return NULL;
 		} else if (tail == NULL) {
 		    *errMsgPtr = missingName;
-		    Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME",
-			    NULL);
 		    return NULL;
 		}
 		if (tail != varName) {
@@ -1001,7 +997,6 @@
 		}
 	    } else {		/* Var wasn't found and not to create it. */
 		*errMsgPtr = noSuchVar;
-		Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", NULL);
 		return NULL;
 	    }
 	}
@@ -1038,7 +1033,6 @@
 	    }
 	    if (varPtr == NULL) {
 		*errMsgPtr = noSuchVar;
-		Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", NULL);
 	    }
 	}
     }
@@ -3621,6 +3615,7 @@
 		myFlags|AVOID_RESOLVERS, /* create */ 1, &errMsg, &index);
 	if (varPtr == NULL) {
 	    TclObjVarErrMsg(interp, myNamePtr, NULL, "create", errMsg, -1);
+	    Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARNAME", NULL);
 	    return TCL_ERROR;
 	}
     }
