namespace import
Closed / Fixed420186ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2001-04-30 16:02:12
Linux SuSE7.1
example:
==> Test1.tcl
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/sh
#\
exec tclsh "$0"
lappend auto_path [ pwd ]
puts [ ::Args::Test::Main ]
<<<<<<<<<<<<<<<<<<<<<<<<<<<<
==> Test2.tcl
>>>>>>>>>>>>>>>>>>>>>>>>>>>
namespace eval ::Args {
namespace export *
}
proc ::Args::P1 {} { return P1 }
namespace eval ::Args::Test {
namespace import ::Args::*
}
proc ::Args::Test::Main {} {
return "P1<[P1]>"
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<
==> tclIndex
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Tcl autoload index file, version 2.0
# This file is generated by the "auto_mkindex" command
# and sourced to set up indexing information for one or
# more commands. Typically each line is a command that
# sets an element in the auto_index array, where the
# element name is the name of a command and the value is
# a script that loads the command.
set auto_index(::Args::P1) [list source [file join $dir Test2.tcl]]
set auto_index(::Args::Test::Main) [list source [file join $dir Test2.tcl]]
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If you run:
./Test1.tcl
you get:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
too many nested calls to Tcl_Eval (infinite loop?)
while executing
"namespace current"
("uplevel" body line 1)
invoked from within
"uplevel namespace current"
(procedure "auto_import" line 4)
invoked from within
"namespace import ::Args::*"
(in namespace eval "::Args::Test" script line 2)
invoked from within
"namespace eval ::Args::Test {
namespace import ::Args::*
}"
(file "/alt/home/dev1usr/Project/Compiler2/test/Config/Test/Test2.tcl"
line 7)
invoked from within
"source /alt/home/dev1usr/Project/Compiler2/test/Config/Test/Test2.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 $auto_index($name)"
(procedure "auto_import" line 12)
invoked from within
"namespace import ::Args::*"
(in namespace eval "::Args::Test" script line 2)
...
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
dgpplain2001-05-01 02:58:57
File Added - 5866: test.tcl Logged In: YES user_id=80530 Attaching a simplified test script, test.tcl Exercise the bug: $ tclsh % auto_mkindex . test.tcl % lappend auto_path . % Args::Test::Main too many nested calls to Tcl_Eval (infinite loop?) The problem seems to be in [auto_import]. It is using a full [string match $pattern] to filter the names in auto_index, but [namespace import] is only interested in matches according to its stricter matching rules. The wildcards should only match on command names, not parent namespaces.
dgpplain2001-05-01 04:01:08
File Added - 5869: import.patch Logged In: YES user_id=80530 Attached patch corrects [auto_import] to do pattern matching in the [namespace import] style. Since there are no other callers of [auto_import], I think this is a safe change in terms of compatibility. I'll commit this to the HEAD tomorrow unless I hear an objection.
hobbsplain2001-05-04 03:38:13
Logged In: YES user_id=72656 looks good to me.
dgpplain2001-05-04 05:35:08
File Deleted - 5869: File Added - 5973: import.patch Logged In: YES user_id=80530 Improved patch include updates to test suite, and improved auto_index filtering (fewer script level iterations).
dgpplain2001-05-04 05:36:09
File Deleted - 5973: File Added - 5974: import.patch
dgpplain2001-05-04 05:39:14
Logged In: YES user_id=80530 Committed.
Log in (anonymous is fine) to add a comment.
Attachments:
- import.patch [download] added by dgp on 2001-05-04 05:36:09. [details]
- test.tcl [download] added by dgp on 2001-05-01 02:58:57. [details]