Index: generic/tclNamesp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclNamesp.c,v
retrieving revision 1.78
diff -u -r1.78 tclNamesp.c
--- generic/tclNamesp.c	5 Jul 2005 17:33:06 -0000	1.78
+++ generic/tclNamesp.c	5 Jul 2005 21:29:01 -0000
@@ -1061,6 +1061,23 @@
     Tcl_InitHashTable(&nsPtr->varTable, TCL_STRING_KEYS);
 
     /*
+     * Delete all commands in this namespace. Be careful when traversing the
+     * hash table: when each command is deleted, it removes itself from the
+     * command table.
+     *
+     * Don't optimize to Tcl_NextHashEntry() because of traces.
+     */
+
+    for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
+	    entryPtr != NULL;
+	    entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search)) {
+	cmd = (Tcl_Command) Tcl_GetHashValue(entryPtr);
+	Tcl_DeleteCommandFromToken((Tcl_Interp *) iPtr, cmd);
+    }
+    Tcl_DeleteHashTable(&nsPtr->cmdTable);
+    Tcl_InitHashTable(&nsPtr->cmdTable, TCL_STRING_KEYS);
+
+    /*
      * Remove the namespace from its parent's child hashtable.
      */
 
@@ -1108,23 +1125,6 @@
     }
 
     /*
-     * Delete all commands in this namespace. Be careful when traversing the
-     * hash table: when each command is deleted, it removes itself from the
-     * command table.
-     *
-     * Don't optimize to Tcl_NextHashEntry() because of traces.
-     */
-
-    for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search);
-	    entryPtr != NULL;
-	    entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search)) {
-	cmd = (Tcl_Command) Tcl_GetHashValue(entryPtr);
-	Tcl_DeleteCommandFromToken((Tcl_Interp *) iPtr, cmd);
-    }
-    Tcl_DeleteHashTable(&nsPtr->cmdTable);
-    Tcl_InitHashTable(&nsPtr->cmdTable, TCL_STRING_KEYS);
-
-    /*
      * Free the namespace's export pattern array.
      */
 
