Tk Library Source Code

View Ticket
Login
Ticket UUID: 795032
Title: [package require uri] alter some vars on global level
Type: Bug Version: None
Submitter: pointsman Created on: 2003-08-26 00:45:20
Subsystem: uri Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2003-08-28 04:27:54
Resolution: Fixed Closed By: patthoyts
    Closed on: 2003-08-27 21:27:54
Description:
This script:

set host test
package require uri
puts $host

returns:
((([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]|[A-Za-z0-9])\.)*([a-zA-Z][A-Za-z0-9-]*[A-Za-z0-9]|[a-zA-Z]))|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))

It's not, that [package require uri] simply pollutes
the global namespace. A

package require uri
puts $host

gives "can't read "host": no such variable" as
expected. The var 'host' must be set prior to the
[package require uri] to be altered by the package request.

The same problem shows with other variable names, for
example 'escape', 'hostOrPort', 'uChar' and very
probably some more.

As far, as I've tracked it down, it seems, that proc
::uri::register or the script args of the various
::uri::register calls at the end of uri.tcl are the
source of the problem.
User Comments: patthoyts added on 2003-08-28 04:27:54:
Logged In: YES 
user_id=202636

Its the various set statements. If the given variable exists
in the global namespace then that is set. Remember that
namespace name resolution looks at the current namespace and
the global namespace only.

The fix is to use variable everywhere -- this passes the
test suite and doesn't affect existing global variables.