Ticket UUID: | 1047286 | |||
Title: | [namespace delete]: command delete traces: cmd already gone | |||
Type: | Bug | Version: | obsolete: 8.5a4 | |
Submitter: | dgp | Created on: | 2004-10-14 19:53:02 | |
Subsystem: | 21. [namespace] | Assigned To: | dgp | |
Priority: | 7 High | Severity: | ||
Status: | Closed | Last Modified: | 2006-03-10 12:09:11 | |
Resolution: | Fixed | Closed By: | dgp | |
Closed on: | 2006-03-10 05:09:11 | |||
Description: |
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. | |||
User Comments: |
dgp added on 2006-03-10 12:09:10:
Logged In: YES user_id=80530 Looks like we overlooked closing this one. msofer added on 2005-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. dgp added on 2005-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. dgp added on 2005-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? msofer added on 2005-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: msofer added on 2005-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. msofer added on 2005-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. msofer added on 2005-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"). dgp added on 2005-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. msofer added on 2005-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. dgp added on 2005-07-06 04:52:18: File Added - 140972: 1047286-84.patch dgp added on 2005-07-06 04:52:17: Logged In: YES user_id=80530 corresponding patch for 8.4 dgp added on 2005-07-06 04:32:05: File Added - 140970: 1047286.patch dgp added on 2005-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. |