Artifacts Associated With Ticket 219385ffffffffff
Ticket change [0eb61f71f7] (rid 94662) by nobody on 2000-10-26 05:12:07:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 6109 Bug Version: 8.4a1 SubmitDate: '2000-08-09' LastModified: '2000-10-25' Severity: MED Status: UnAssn Submitter: techsupp OS: All FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: Don Porter ReproducibleScript: namespace eval test_ns_1 { variable v 42 } namespace eval test_ns_2 { proc namespace args {} } namespace eval test_ns_2 [namespace eval test_ns_1 { namespace code {set v} }] ObservedBehavior: The example script returns the empty string. It should return 42, according to the documentation of [namespace code]: namespace code script Captures the current namespace context for later execu- tion of the script script. It returns a new script in which script has been wrapped in a namespace code com- mand. The new script has two important properties. First, it can be evaluated in any namespace and will cause script to be evaluated in the current namespace (the one where the namespace code command was invoked). Note the guarantee is for "any namespace". This guarantee includes those namespaces which have been silly enough to redefine the [namespace] command. DesiredBehavior: [namespace code] should behave as documented. Patch: Index: generic/tclNamesp.c =================================================================== RCS file: /cvsroot/tcl/generic/tclNamesp.c,v retrieving revision 1.18 diff -c -r1.18 tclNamesp.c *** tclNamesp.c 2000/05/11 00:17:29 1.18 --- tclNamesp.c 2000/08/09 17:06:42 *************** *** 2639,2648 **** * Here "arg" can be a list. "namespace code arg" produces a result * equivalent to that produced by the command * ! * list namespace inscope [namespace current] $arg * * However, if "arg" is itself a scoped value starting with ! * "namespace inscope", then the result is just "arg". * * Results: * Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong. --- 2639,2648 ---- * Here "arg" can be a list. "namespace code arg" produces a result * equivalent to that produced by the command * ! * list ::namespace inscope [namespace current] $arg * * However, if "arg" is itself a scoped value starting with ! * "::namespace inscope", then the result is just "arg". * * Results: * Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong. *************** *** 2676,2681 **** --- 2676,2685 ---- */ arg = Tcl_GetStringFromObj(objv[2], &length); + while (*arg == ':') { + arg++; + length--; + } if ((*arg == 'n') && (length > 17) && (strncmp(arg, "namespace", 9) == 0)) { for (p = (arg + 9); (*p == ' '); p++) { *************** *** 2698,2704 **** listPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); Tcl_ListObjAppendElement(interp, listPtr, ! Tcl_NewStringObj("namespace", -1)); Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj("inscope", -1)); --- 2702,2708 ---- listPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); Tcl_ListObjAppendElement(interp, listPtr, ! Tcl_NewStringObj("::namespace", -1)); Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj("inscope", -1)); Index: library/init.tcl =================================================================== RCS file: /cvsroot/tcl/library/init.tcl,v retrieving revision 1.41 diff -c -r1.41 init.tcl *** init.tcl 2000/05/18 21:37:19 1.41 --- init.tcl 2000/08/09 17:12:54 *************** *** 163,169 **** # then concatenate its arguments onto the end and evaluate it. set cmd [lindex $args 0] ! if {[regexp "^namespace\[ \t\n\]+inscope" $cmd] && [llength $cmd] == 4} { set arglist [lrange $args 1 end] set ret [catch {uplevel $cmd $arglist} result] if {$ret == 0} { --- 163,169 ---- # then concatenate its arguments onto the end and evaluate it. set cmd [lindex $args 0] ! if {[regexp "^:*namespace\[ \t\n\]+inscope" $cmd] && [llength $cmd] == 4} { set arglist [lrange $args 1 end] set ret [catch {uplevel $cmd $arglist} result] if {$ret == 0} { Index: tests/namespace-old.test =================================================================== RCS file: /cvsroot/tcl/tests/namespace-old.test,v retrieving revision 1.5 diff -c -r1.5 namespace-old.test *** namespace-old.test 2000/04/10 17:19:02 1.5 --- namespace-old.test 2000/08/09 17:06:43 *************** *** 804,820 **** namespace eval test_ns_inscope { namespace code {"1 2 3" "4 5" 6} } ! } {namespace inscope ::test_ns_inscope {"1 2 3" "4 5" 6}} test namespace-old-10.5 {with one arg, first "scope" sticks} { set sval [namespace eval test_ns_inscope {namespace code {one two}}] namespace code $sval ! } {namespace inscope ::test_ns_inscope {one two}} test namespace-old-10.6 {with many args, each "scope" adds new args} { set sval [namespace eval test_ns_inscope {namespace code {one two}}] namespace code "$sval three" ! } {namespace inscope ::test_ns_inscope {one two} three} test namespace-old-10.7 {scoped commands work with eval} { set cref [namespace eval test_ns_inscope {namespace code show}] --- 804,820 ---- namespace eval test_ns_inscope { namespace code {"1 2 3" "4 5" 6} } ! } {::namespace inscope ::test_ns_inscope {"1 2 3" "4 5" 6}} test namespace-old-10.5 {with one arg, first "scope" sticks} { set sval [namespace eval test_ns_inscope {namespace code {one two}}] namespace code $sval ! } {::namespace inscope ::test_ns_inscope {one two}} test namespace-old-10.6 {with many args, each "scope" adds new args} { set sval [namespace eval test_ns_inscope {namespace code {one two}}] namespace code "$sval three" ! } {::namespace inscope ::test_ns_inscope {one two} three} test namespace-old-10.7 {scoped commands work with eval} { set cref [namespace eval test_ns_inscope {namespace code show}] Index: tests/namespace.test =================================================================== RCS file: /cvsroot/tcl/tests/namespace.test,v retrieving revision 1.13 diff -c -r1.13 namespace.test *** namespace.test 2000/05/11 00:17:29 1.13 --- namespace.test 2000/08/09 17:06:44 *************** *** 694,705 **** } {namespace inscope ::test_ns_1 cmd} test namespace-22.4 {NamespaceCodeCmd, in :: namespace} { namespace code unknown ! } {namespace inscope :: unknown} test namespace-22.5 {NamespaceCodeCmd, in other namespace} { namespace eval test_ns_1 { namespace code cmd } ! } {namespace inscope ::test_ns_1 cmd} test namespace-23.1 {NamespaceCurrentCmd, bad args} { catch {eval namespace delete [namespace children :: test_ns_*]} --- 694,716 ---- } {namespace inscope ::test_ns_1 cmd} test namespace-22.4 {NamespaceCodeCmd, in :: namespace} { namespace code unknown ! } {::namespace inscope :: unknown} test namespace-22.5 {NamespaceCodeCmd, in other namespace} { namespace eval test_ns_1 { namespace code cmd } ! } {::namespace inscope ::test_ns_1 cmd} ! test namespace-22.5 {NamespaceCodeCmd, in other namespace} { ! namespace eval test_ns_1 { ! variable v 42 ! } ! namespace eval test_ns_2 { ! proc namespace args {} ! } ! namespace eval test_ns_2 [namespace eval test_ns_1 { ! namespace code {set v} ! }] ! } {42} test namespace-23.1 {NamespaceCurrentCmd, bad args} { catch {eval namespace delete [namespace children :: test_ns_*]} PatchFiles: generic/tclNamesp.c library/init.tcl tests/namespace-old.test tests/namespace.test - foundin initialized to: "obsolete: 8.4a1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "[namespace code] failure"
- type initialized to: "Bug"
Ticket change [c88326a9dd] (rid 122114) by dkf on 2001-01-31 17:50:26:
- subsystem changed to: "21. [namespace]"
Ticket change [f237db22d9] (rid 109501) by dgp on 2001-02-01 02:11:28:
- icomment:
Registered patch as # 103530
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [4803f51749] (rid 99813) by msofer on 2001-02-27 04:28:42:
- assignee changed to: "msofer"
Ticket change [5e96ce312e] (rid 115663) by msofer on 2001-04-07 08:59:49:
- icomment:
File Added - 5101: patch Logged In: YES user_id=148712 Patch #403530
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Add attachment "patch" [b896b6924f] (rid 128989) by msofer on 2001-04-07 08:59:49.
Ticket change [a044c78936] (rid 96773) by msofer on 2001-04-07 09:39:00:
- closedate changed to: "2001-04-07T02:39:00"
- closer changed to: "msofer"
- status changed to: "Closed"
Ticket change [57a2f599cf] (rid 117651) by msofer on 2001-04-07 10:36:15:
- closedate changed to: "2001-04-07T03:36:15"
- closer changed to: "msofer"
- resolution changed to: "Fixed"