Attachment "1230597.patch" to
ticket [1230597fff]
added by
dgp
2005-07-01 21:30:43.
Index: generic/tclNamesp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclNamesp.c,v
retrieving revision 1.31.2.6
diff -u -r1.31.2.6 tclNamesp.c
--- generic/tclNamesp.c 5 Oct 2004 16:22:34 -0000 1.31.2.6
+++ generic/tclNamesp.c 1 Jul 2005 14:28:35 -0000
@@ -1277,6 +1277,16 @@
refPtr->nextPtr = cmdPtr->importRefPtr;
cmdPtr->importRefPtr = refPtr;
} else {
+ Command *overwrite = (Command *) Tcl_GetHashValue(found);
+ if (overwrite->deleteProc == DeleteImportedCmd) {
+ ImportedCmdData *dataPtr =
+ (ImportedCmdData *) overwrite->objClientData;
+ if (dataPtr->realCmdPtr
+ == (Command *) Tcl_GetHashValue(hPtr)) {
+ /* Repeated import of same command -- acceptable */
+ return TCL_OK;
+ }
+ }
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"can't import command \"", cmdName,
"\": already exists", (char *) NULL);
Index: tests/namespace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/namespace.test,v
retrieving revision 1.21.2.5
diff -u -r1.21.2.5 namespace.test
--- tests/namespace.test 28 Oct 2004 00:01:11 -0000 1.21.2.5
+++ tests/namespace.test 1 Jul 2005 14:28:36 -0000
@@ -244,7 +244,7 @@
} {cmd1: 123}
test namespace-9.5 {Tcl_Import, can't redefine cmd unless allowOverwrite!=0} {
list [catch {namespace eval test_ns_import {namespace import ::test_ns_export::*}} msg] $msg
-} {1 {can't import command "cmd1": already exists}}
+} {0 {}}
test namespace-9.6 {Tcl_Import, cmd redefinition ok if allowOverwrite!=0} {
namespace eval test_ns_import {
namespace import -force ::test_ns_export::*