Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-03-10
12:09 • Ticket [1047286fff] namespace delete: command delete traces: cmd already gone<... artifact: abece98081 user: dgp
12:09 • Closed ticket [1047286fff]. artifact: 9060d320c3 user: dgp
2005-11-19
06:47 • Ticket [1047286fff]: 5 changes artifact: 8b421b86c5 user: msofer
2005-11-15
01:18 • Ticket [1047286fff]: 4 changes artifact: 7775c279a1 user: dgp
2005-11-14
23:53 • Ticket [1047286fff]: 4 changes artifact: 74359a36a6 user: dgp
23:53 • Ticket [1047286fff]: 1 change artifact: 75450a7a44 user: dgp
22:03 • Ticket [1047286fff]: 4 changes artifact: ee36a08325 user: msofer
08:12 • Ticket [1047286fff]: 4 changes artifact: 432c753aae user: msofer
08:08 • Open ticket [1047286fff]. artifact: b959b0905a user: msofer
2005-10-31
06:31 • Pending ticket [1047286fff]. artifact: b8b0a01a02 user: msofer
2005-07-26
23:24 • Closed ticket [1047286fff]. artifact: 7d4ab0b81c user: dgp
23:06 • Ticket [1047286fff]: 5 changes artifact: 01791e0c89 user: msofer
2005-07-06
04:52 • Add attachment 1047286-84.patch to ticket [1047286fff] artifact: c5c231856a user: dgp
04:52 • Ticket [1047286fff] namespace delete: command delete traces: cmd already gone<... artifact: f48cc9f0ff user: dgp
04:52 • Ticket [1047286fff]: 4 changes artifact: 646f9af440 user: dgp
04:32 • Ticket [1047286fff]: 4 changes artifact: 590372de6f user: dgp
04:32 • Add attachment 1047286.patch to ticket [1047286fff] artifact: 8a03e9e069 user: dgp
04:32 • Ticket [1047286fff] namespace delete: command delete traces: cmd already gone<... artifact: 9206969d00 user: dgp
2004-10-14
19:53 • New ticket [1047286fff]. artifact: a844be23da user: dgp

[namespace delete]: command delete traces: cmd already gone

Closed / Fixed1047286fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 21 years ago
Descriptionplain2004-10-14 19:53:02
When command delete traces fire,
the command is supposed to still
be there (even though you cannot
stop its deletion).  Like so:

% proc callback {old - -} {
    puts "$old exists: [namespace which $old]"
}
% proc bar {} {}
% trace add command bar delete callback
% rename bar {}
::bar exists: ::bar


However TclTeardownNamespace
deletes access to commands before
deleting the commands (and thus
firing their delete traces).  See:

% namespace eval foo {proc bar {} {}}
% trace add command foo::bar delete callback
% namespace delete foo
::foo::bar exists: 
unknown command "::foo::bar"

Some re-ordering in TTN() is needed.
dgpplain2005-07-06 04:32:04
Logged In: YES 
user_id=80530


Attached patch is a simple
reordering of TclTeardownNamespace
that corrects the reported problem
and passes the test suite.

Needs further review.
dgpplain2005-07-06 04:32:05
File Added - 140970: 1047286.patch
dgpplain2005-07-06 04:52:17
Logged In: YES 
user_id=80530


corresponding patch for 8.4
dgpplain2005-07-06 04:52:18
File Added - 140972: 1047286-84.patch
msoferplain2005-07-26 23:06:46
Logged In: YES 
user_id=148712

Patches look good.

Is it  possible that some code in the wild might be relying
on this behaviour (or using ad-hoc workarounds that this
could break)? I'm not sure if I'd risk fixing the 8.4 branch.
dgpplain2005-07-26 23:24:40
Logged In: YES 
user_id=80530

[12:07]dgpI don't think that's a problem.
[12:08]dgpcommand traces first arrived in Tcl 8.4, so
there's not going to be any ancient code involved.
[12:08]dgpand the 8.4.x patch releases are supposed to be
for fixing the 8.4 bugs.

patches committed.
Added a test based on the example in the report.
msoferplain2005-10-31 06:31:45
Logged In: YES 
user_id=148712

Please note that the behaviour for delete traces on
variables is spec'ed differently: the variable is supposed
not to exist while the delete trace fires - see Bug #1338280

Is there some deep reason for this difference? I can't find
a related tip (tip62 mentions that "Tcl8.4 has already added
support for tracing rename or delete operations on Tcl
commands").
msoferplain2005-11-14 08:08:01
Logged In: YES 
user_id=148712

This bug is not 100% fixed: witness the test namespace-7.4.

There seems to be an inconsistency here: during the call to
[namespace delete], the namespace is supposedly not
resolvable anymore (according to the man page). This seems
to disagree violently with the expectations in this bug report. 

The current implementation insures unresolvability if the
call to [ns delete] occurs when the namespace is not in the
call stack (ie, activationCount==0) [that it does only in
this case may be an independent bug]. Namespace-7.4 fails
not because the command does not exist, but because it can
not be resolved by name; I suppose that if it is imported to
another namespace, it does work when resolved there.

Not sure what the correct behaviour might be. I tend to
prefer that the command not be resolvable during a delete
trace triggered by the namespace deletion - because the
namespace itself is not resolvable.
msoferplain2005-11-14 08:12:08
Logged In: YES 
user_id=148712

Rats - forget about namespace-7.4 (completely unrelated,
looking in a buggy sandbox. Sorry.)

Comments still stand on their own merit.
msoferplain2005-11-14 22:03:33
Logged In: YES 
user_id=148712

To illustrate the difference between 'ns in stack' and 'ns
not in stack':

% info patch
8.5a4
% namespace eval foo {proc bar {} {}}
% trace add command foo::bar delete callback
% namespace delete foo
::foo::bar exists: ::foo::bar
%
% namespace eval foo {proc bar {} {}}
% trace add command foo::bar delete callback
% namespace eval foo {namespace delete [namespace current]}
::foo::bar exists:
dgp Ticket [1047286fff]: 1 change [History diff]2005-11-14 23:53:02
dgpplain2005-11-14 23:53:03
Logged In: YES 
user_id=80530


I don't like that at all.

At least before I had the choice
of a successful [namespace which]
or an error.  A [namespace which]
that apparently succeeds but returns
an empty string is unsettling.

How do we fix it?
dgpplain2005-11-15 01:18:16
Logged In: YES 
user_id=80530


sorry, mis-recalled the docs
for [namespace which].
Empty string return is correct
for non-existent command.
msoferplain2005-11-19 06:47:24
Logged In: YES 
user_id=148712

Added test trace-34.5 to illustrate the the role of "ns in
callStack" in the ns's visibility during deletion traces.
dgpplain2006-03-10 12:09:10
Logged In: YES 
user_id=80530



Looks like we overlooked
closing this one.
dgp Ticket [1047286fff]: 2 changes [History diff]2006-03-10 12:09:11
Log in (anonymous is fine) to add a comment.

Attachments: