Index: generic/tclTrace.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTrace.c,v
retrieving revision 1.51
diff -u -r1.51 tclTrace.c
--- generic/tclTrace.c	5 Sep 2008 01:20:00 -0000	1.51
+++ generic/tclTrace.c	7 Oct 2008 17:50:42 -0000
@@ -2672,53 +2672,41 @@
   done:
     if (code == TCL_ERROR) {
 	if (leaveErrMsg) {
+	    const char *verb = "";
 	    const char *type = "";
-	    Tcl_Obj *options = Tcl_GetReturnOptions((Tcl_Interp *)iPtr, code);
-	    Tcl_Obj *errorInfoKey, *errorInfo;
 
-	    TclNewLiteralStringObj(errorInfoKey, "-errorinfo");
-	    Tcl_IncrRefCount(errorInfoKey);
-	    Tcl_DictObjGet(NULL, options, errorInfoKey, &errorInfo);
-	    Tcl_IncrRefCount(errorInfo);
-	    Tcl_DictObjRemove(NULL, options, errorInfoKey);
-	    if (Tcl_IsShared(errorInfo)) {
-		Tcl_DecrRefCount(errorInfo);
-		errorInfo = Tcl_DuplicateObj(errorInfo);
-		Tcl_IncrRefCount(errorInfo);
-	    }
-	    Tcl_AppendToObj(errorInfo, "\n    (", -1);
 	    switch (flags&(TCL_TRACE_READS|TCL_TRACE_WRITES|TCL_TRACE_ARRAY)) {
 	    case TCL_TRACE_READS:
-		type = "read";
-		Tcl_AppendToObj(errorInfo, type, -1);
+		verb = "read";
+		type = verb;
 		break;
 	    case TCL_TRACE_WRITES:
-		type = "set";
-		Tcl_AppendToObj(errorInfo, "write", -1);
+		verb = "set";
+		type = "write";
 		break;
 	    case TCL_TRACE_ARRAY:
-		type = "trace array";
-		Tcl_AppendToObj(errorInfo, "array", -1);
+		verb = "trace array";
+		type = "array";
 		break;
 	    }
+
 	    if (disposeFlags & TCL_TRACE_RESULT_OBJECT) {
-		TclVarErrMsg((Tcl_Interp *) iPtr, part1, part2, type,
-			Tcl_GetString((Tcl_Obj *) result));
+		Tcl_SetObjResult((Tcl_Interp *)iPtr, (Tcl_Obj *) result);
 	    } else {
-		TclVarErrMsg((Tcl_Interp *) iPtr, part1, part2, type, result);
+		Tcl_SetResult((Tcl_Interp *)iPtr, result, TCL_STATIC);
 	    }
-	    Tcl_AppendToObj(errorInfo, " trace on \"", -1);
-	    Tcl_AppendToObj(errorInfo, part1, -1);
-	    if (part2 != NULL) {
-		Tcl_AppendToObj(errorInfo, "(", -1);
-		Tcl_AppendToObj(errorInfo, part1, -1);
-		Tcl_AppendToObj(errorInfo, ")", -1);
+	    Tcl_AddErrorInfo((Tcl_Interp *)iPtr, "");
+
+	    Tcl_AppendObjToErrorInfo((Tcl_Interp *)iPtr, Tcl_ObjPrintf(
+		    "\n    (%s trace on \"%s%s%s%s\")", type, part1,
+		    (part2 ? "(" : ""), (part2 ? part2 : ""),
+		    (part2 ? ")" : "") ));
+	    if (disposeFlags & TCL_TRACE_RESULT_OBJECT) {
+		TclVarErrMsg((Tcl_Interp *) iPtr, part1, part2, verb,
+			Tcl_GetString((Tcl_Obj *) result));
+	    } else {
+		TclVarErrMsg((Tcl_Interp *) iPtr, part1, part2, verb, result);
 	    }
-	    Tcl_AppendToObj(errorInfo, "\")", -1);
-	    Tcl_DictObjPut(NULL, options, errorInfoKey, errorInfo);
-	    Tcl_DecrRefCount(errorInfoKey);
-	    Tcl_DecrRefCount(errorInfo);
-	    code = Tcl_SetReturnOptions((Tcl_Interp *) iPtr, options);
 	    iPtr->flags &= ~(ERR_ALREADY_LOGGED);
 	    Tcl_DiscardInterpState(state);
 	} else {
Index: generic/tclVar.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclVar.c,v
retrieving revision 1.168
diff -u -r1.168 tclVar.c
--- generic/tclVar.c	25 Sep 2008 19:51:29 -0000	1.168
+++ generic/tclVar.c	7 Oct 2008 17:50:42 -0000
@@ -4641,16 +4641,13 @@
 				 * variable, or -1. Only used when part1Ptr is
 				 * NULL. */
 {
-    Tcl_ResetResult(interp);
     if (!part1Ptr) {
 	part1Ptr = localName(((Interp *)interp)->varFramePtr, index);
     }
-    Tcl_AppendResult(interp, "can't ", operation, " \"",
-	    TclGetString(part1Ptr), NULL);
-    if (part2Ptr) {
-	Tcl_AppendResult(interp, "(", TclGetString(part2Ptr), ")", NULL);
-    }
-    Tcl_AppendResult(interp, "\": ", reason, NULL);
+    Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't %s \"%s%s%s%s\": %s",
+	    operation, TclGetString(part1Ptr), (part2Ptr ? "(" : ""),
+	    (part2Ptr ? TclGetString(part2Ptr) : ""), (part2Ptr ? ")" : ""),
+	    reason));
 }
 
 /*
