Index: generic/tclCmdMZ.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdMZ.c,v
retrieving revision 1.82.2.25
diff -u -r1.82.2.25 tclCmdMZ.c
--- generic/tclCmdMZ.c	18 Nov 2005 23:07:27 -0000	1.82.2.25
+++ generic/tclCmdMZ.c	11 Apr 2006 14:08:58 -0000
@@ -4579,10 +4579,9 @@
 	 */
 	if (call) {
 	    Tcl_SavedResult state;
-	    int stateCode;
+	    int stateCode, i, saveInterpFlags;
 	    Tcl_DString cmd;
 	    Tcl_DString sub;
-	    int i;
 
 	    Tcl_DStringInit(&cmd);
 	    Tcl_DStringAppend(&cmd, tcmdPtr->command, (int)tcmdPtr->length);
@@ -4636,8 +4635,9 @@
 	    Tcl_SaveResult(interp, &state);
 	    stateCode = iPtr->returnCode;
 
-	    tcmdPtr->flags |= TCL_TRACE_EXEC_IN_PROGRESS;
+	    saveInterpFlags = iPtr->flags;
 	    iPtr->flags    |= INTERP_TRACE_IN_PROGRESS;
+	    tcmdPtr->flags |= TCL_TRACE_EXEC_IN_PROGRESS;
 	    tcmdPtr->refCount++;
 	    /* 
 	     * This line can have quite arbitrary side-effects,
@@ -4646,7 +4646,12 @@
 	     */
 	    traceCode = Tcl_Eval(interp, Tcl_DStringValue(&cmd));
 	    tcmdPtr->flags &= ~TCL_TRACE_EXEC_IN_PROGRESS;
-	    iPtr->flags    &= ~INTERP_TRACE_IN_PROGRESS;
+
+	    /*
+	     * Restore the interp tracing flag to prevent cmd traces
+	     * from affecting interp traces
+	     */
+	    iPtr->flags = saveInterpFlags;;
 	    if (tcmdPtr->flags == 0) {
 		flags |= TCL_TRACE_DESTROYED;
 	    }
Index: tests/trace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/trace.test,v
retrieving revision 1.26.2.15
diff -u -r1.26.2.15 trace.test
--- tests/trace.test	28 Feb 2006 15:44:36 -0000	1.26.2.15
+++ tests/trace.test	11 Apr 2006 14:08:58 -0000
@@ -2325,6 +2325,43 @@
     set x
 } {::foo::bar exists: }
 
+test trace-34.6 {Bug 1458266} -setup {
+    proc dummy {} {}
+    proc stepTraceHandler {cmdString args} {
+	variable log 
+	append log "[expr {[info level] - 1}]: [lindex [split $cmdString] 0]\n"
+	dummy
+	isTracedInside_2
+    }
+    proc cmdTraceHandler {cmdString args} {
+	# silent
+    }
+    proc isTracedInside_1 {} {
+	isTracedInside_2
+    }
+    proc isTracedInside_2 {} {
+	set x 2
+    }
+} -body {
+    variable log {}
+    trace add execution isTracedInside_1 enterstep stepTraceHandler
+    trace add execution isTracedInside_2 enterstep stepTraceHandler
+    isTracedInside_1
+    variable first $log
+    set log {}
+    trace add execution dummy enter cmdTraceHandler
+    isTracedInside_1
+    variable second $log
+    expr {($first eq $second) ? "ok" : "\n$first\nand\n\n$second\ndiffer"}
+} -cleanup {
+    unset -nocomplain log first second
+    rename dummy {}
+    rename stepTraceHandler {}
+    rename cmdTraceHandler {}
+    rename isTracedInside_1 {}
+    rename isTracedInside_2 {}
+} -result ok
+
 # Delete procedures when done, so we don't clash with other tests
 # (e.g. foobar will clash with 'unknown' tests).
 catch {rename foobar {}}
