Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 227074bce42f8749ffb6feb421b28b20aff3d746
Ticket: 219422ffffffffffffffffffffffffffffffffff
[uplevel] assumes caller cmd definitions
User & Date: nobody on 2000-10-26 05:12:57
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    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
    
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.4a1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "[uplevel] assumes caller cmd definitions"
  11. type changed to: "Bug"