[uplevel] assumes caller cmd definitions
Closed / Fixed219422ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 05:12:57
OriginalBugID: 6086 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
ObservedBehavior:
Several parts of the Tcl script library and its
included packages use the [uplevel] command
assuming the built-in command names in the caller's
context actually refer to the built-in commands.
Since the caller can be in a namespace where commands
have been redefined, such assumptions should not be
made.
The included patch fixes these errors.
Patch:
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:41:17
***************
*** 163,171 ****
# 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} {
return $result
} else {
--- 163,171 ----
# 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} {
return $result
} else {
***************
*** 188,194 ****
return -code error "self-referential recursion in \"unknown\" for command \"$name\"";
}
set unknown_pending($name) pending;
! set ret [catch {auto_load $name [uplevel 1 {namespace current}]} msg]
unset unknown_pending($name);
if {$ret != 0} {
append errorInfo "\n (autoloading \"$name\")"
--- 188,194 ----
return -code error "self-referential recursion in \"unknown\" for command \"$name\"";
}
set unknown_pending($name) pending;
! set ret [catch {auto_load $name [uplevel 1 {::namespace current}]} msg]
unset unknown_pending($name);
if {$ret != 0} {
append errorInfo "\n (autoloading \"$name\")"
***************
*** 286,292 ****
global auto_index auto_oldpath auto_path
if {[string length $namespace] == 0} {
! set namespace [uplevel {namespace current}]
}
set nameList [auto_qualify $cmd $namespace]
# workaround non canonical auto_index entries that might be around
--- 286,292 ----
global auto_index auto_oldpath auto_path
if {[string length $namespace] == 0} {
! set namespace [uplevel {::namespace current}]
}
set nameList [auto_qualify $cmd $namespace]
# workaround non canonical auto_index entries that might be around
***************
*** 461,467 ****
return
}
! set ns [uplevel namespace current]
set patternList [auto_qualify $pattern $ns]
auto_load_index
--- 461,467 ----
return
}
! set ns [uplevel ::namespace current]
set patternList [auto_qualify $pattern $ns]
auto_load_index
Index: library/msgcat1.0/msgcat.tcl
===================================================================
RCS file: /cvsroot/tcl/library/msgcat1.0/msgcat.tcl,v
retrieving revision 1.7
diff -c -r1.7 msgcat.tcl
*** msgcat.tcl 2000/07/17 22:25:26 1.7
--- msgcat.tcl 2000/08/09 17:41:18
***************
*** 12,18 ****
#
# RCS: @(#) $Id: msgcat.tcl,v 1.7 2000/07/17 22:25:26 ericm Exp $
! package provide msgcat 1.1
namespace eval msgcat {
namespace export mc mcset mcmset mclocale mcpreferences mcunknown mcmax
--- 12,18 ----
#
# RCS: @(#) $Id: msgcat.tcl,v 1.7 2000/07/17 22:25:26 ericm Exp $
! package provide msgcat 1.2
namespace eval msgcat {
namespace export mc mcset mcmset mclocale mcpreferences mcunknown mcmax
***************
*** 49,55 ****
# Check for the src in each namespace starting from the local and
# ending in the global.
! set ns [uplevel {namespace current}]
while {$ns != ""} {
foreach loc $::msgcat::loclist {
--- 49,55 ----
# Check for the src in each namespace starting from the local and
# ending in the global.
! set ns [uplevel {::namespace current}]
while {$ns != ""} {
foreach loc $::msgcat::loclist {
***************
*** 136,142 ****
incr x
set fid [open $langfile "r"]
fconfigure $fid -encoding utf-8
! uplevel [list eval [read $fid]]
close $fid
}
}
--- 136,142 ----
incr x
set fid [open $langfile "r"]
fconfigure $fid -encoding utf-8
! uplevel [read $fid]
close $fid
}
}
***************
*** 161,167 ****
set dest $src
}
! set ns [uplevel {namespace current}]
set ::msgcat::msgs([string tolower $locale],$ns,$src) $dest
return $dest
--- 161,167 ----
set dest $src
}
! set ns [uplevel {::namespace current}]
set ::msgcat::msgs([string tolower $locale],$ns,$src) $dest
return $dest
***************
*** 186,192 ****
}
set locale [string tolower $locale]
! set ns [uplevel {namespace current}]
foreach {src dest} $pairs {
set ::msgcat::msgs($locale,$ns,$src) $dest
--- 186,192 ----
}
set locale [string tolower $locale]
! set ns [uplevel {::namespace current}]
foreach {src dest} $pairs {
set ::msgcat::msgs($locale,$ns,$src) $dest
Index: library/msgcat1.0/pkgIndex.tcl
===================================================================
RCS file: /cvsroot/tcl/library/msgcat1.0/pkgIndex.tcl,v
retrieving revision 1.2
diff -c -r1.2 pkgIndex.tcl
*** pkgIndex.tcl 1999/04/16 00:47:17 1.2
--- pkgIndex.tcl 2000/08/09 17:41:18
***************
*** 1 ****
! package ifneeded msgcat 1.0 [list source [file join $dir msgcat.tcl]]
--- 1 ----
! package ifneeded msgcat 1.2 [list source [file join $dir msgcat.tcl]]
Index: library/opt0.4/optparse.tcl
===================================================================
RCS file: /cvsroot/tcl/library/opt0.4/optparse.tcl,v
retrieving revision 1.4
diff -c -r1.4 optparse.tcl
*** optparse.tcl 2000/07/18 21:30:41 1.4
--- optparse.tcl 2000/08/09 17:41:18
***************
*** 10,16 ****
#
# RCS: @(#) $Id: optparse.tcl,v 1.4 2000/07/18 21:30:41 ericm Exp $
! package provide opt 0.4.1
namespace eval ::tcl {
--- 10,16 ----
#
# RCS: @(#) $Id: optparse.tcl,v 1.4 2000/07/18 21:30:41 ericm Exp $
! package provide opt 0.4.2
namespace eval ::tcl {
***************
*** 252,258 ****
# (the other will be sets to their default value)
# into local variable named "Args".
proc ::tcl::OptProc {name desc body} {
! set namespace [uplevel namespace current];
if { ([string match "::*" $name])
|| ([string compare $namespace "::"]==0)} {
# absolute name or global namespace, name is the key
--- 252,258 ----
# (the other will be sets to their default value)
# into local variable named "Args".
proc ::tcl::OptProc {name desc body} {
! set namespace [uplevel ::namespace current];
if { ([string match "::*" $name])
|| ([string compare $namespace "::"]==0)} {
# absolute name or global namespace, name is the key
***************
*** 262,268 ****
set key "${namespace}::${name}";
}
OptKeyRegister $desc $key;
! uplevel [list proc $name args "set Args \[::tcl::OptKeyParse $key \$args\]\n$body"];
return $key;
}
# Check that a argument has been given
--- 262,268 ----
set key "${namespace}::${name}";
}
OptKeyRegister $desc $key;
! uplevel [list ::proc $name args "set Args \[::tcl::OptKeyParse $key \$args\]\n$body"];
return $key;
}
# Check that a argument has been given
***************
*** 1055,1061 ****
set lg [llength $list];
foreach vname $args {
if {$i>=$lg} break
! uplevel [list set $vname [lindex $list $i]];
incr i;
}
return $lg;
--- 1055,1061 ----
set lg [llength $list];
foreach vname $args {
if {$i>=$lg} break
! uplevel [list ::set $vname [lindex $list $i]];
incr i;
}
return $lg;
Index: library/opt0.4/pkgIndex.tcl
===================================================================
RCS file: /cvsroot/tcl/library/opt0.4/pkgIndex.tcl,v
retrieving revision 1.2
diff -c -r1.2 pkgIndex.tcl
*** pkgIndex.tcl 1999/04/16 00:47:19 1.2
--- pkgIndex.tcl 2000/08/09 17:41:18
***************
*** 8,11 ****
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
! package ifneeded opt 0.4.1 [list source [file join $dir optparse.tcl]]
--- 8,11 ----
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
! package ifneeded opt 0.4.2 [list source [file join $dir optparse.tcl]]
PatchFiles:
library/init.tcl
library/msgcat1.0/msgcat.tcl
library/msgcat1.0/pkgIndex.tcl
library/opt0.4/optParse.tcl
library/opt0.4/pkgIndex.tcl
dgpplain2000-11-27 22:30:24
The fix committed for Bug 123217 conflicts with the patch associated with Bug 119422. Assigning 119422 to myself to resolve the conflict.
dgpplain2000-11-27 23:09:56
Patch 102545 is a revised patch suitable for Tcl 8.4a2 plus the changes related to bug 123217.
dgpplain2000-12-11 11:21:08
Fixed by integration of Patch 102545.
Log in (anonymous is fine) to add a comment.