Tcl_NRCmdSwap prevents exception handling
Closed / Accepted2502002fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 13 years ago
Descriptionplain2009-01-12 18:01:17
When Tcl_NRCmdSwap() is called, there is no call to TEOV_PushExceptionHandlers(), so no handling of toplevel exception and no appending to -errorinfo when TCL_ERROR arises. This seems to be the right feature set for [namespace import]ed commands, which is the sole Tcl_NRCmdSwap() caller in our sources. It's less clear that other T_NRCS() callers want the same thing. At least the docs need to be clearer about it.
msoferplain2009-01-13 02:50:48
I call a possible doc bug: T_NCRS is meant to do precisely what imports do, replace the original command with a new one. In particular, the swap should not add new exception handlers - exceptions are treated only by the original command, not by the replacement. If both the original and the replacement commands are meant to handle exceptions the proper approach is to mimic what aliases do: eval a new objc/objv.
dgpplain2009-01-13 04:41:08
Thanks for commenting miguel. The matter arises as I look into Tcl Bug 2486550. TclObjInvoke() directly calls a cmdPtr->objProc just like the InvokeImportedCmd() used to do. Since T_NCRS() solved one, it's a candidate to solve the other as well. But TOI does include code to append to the -errorinfo .
dgpplain2009-01-13 04:53:39
If TclNREvalObjv() were revised so that a T_NCRS() call still tried a TEOV_PEH() call before skipping the command resolution stuff, then InvokeImportedCmd() could still run exactly as it does now by just passing the TCL_EVAL_NOERR flag, and TOI could use the same routine not passing it.
kennykbplain2009-01-13 08:19:33
Is there a reason this is assigned to me? I committed the NRE documentation while miguel was _hors de combat_, but I think he'd be a better choice to examine it first.
dgpplain2009-01-13 11:21:59
when I first filed, I assumed miguel was still incommunicado, and also assumed this was basically a docs bug. Neither is turning out to be completely true.
msofer Ticket [2502002fff]: 1 change
[History diff]2009-05-01 08:24:16
msofer Ticket [2502002fff]: 1 change
[History diff]2009-05-01 08:26:40
dgpplain2013-03-19 20:35:49
status?
msoferplain2013-03-19 20:52:30
dgp's proposed solution sounds good.
dgpplain2013-04-09 03:08:16
See branch bug-2502002 for work in progress.
dgpplain2013-08-29 19:20:37
merged to trunk.
Log in (anonymous is fine) to add a comment.