| Ticket UUID: | 1428575 | ||
| Title: | Revise Tcl_(Set|Get)ChannelError(Interp) interface | ||
| Type: | RFE | Created on: | 2006-02-09 19:39:30 |
| Submitter: | dgp | Assigned to: | dgp |
| Subsystem: | 25. Channel System | Severity: | |
| Priority: | 7 High | Last modified: | 2007-11-27 01:26:43 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | None | ||
| Description: | ||||
TIP 219 confronted the difficult problem that the Tcl_Channel extension interface doesn't permit easy reporting of error information in the usual Tcl manner (code + msg + return options dictionary), but has a history of returning only a POSIX-style error code, a choice laid down long ago, apparently inspired by unix examples. The TIP 219 solution was to provide a pair of "bypass" areas where error information could be stored and retrieved. One area is attached to the Tcl_Interp; the other within the ChannelState struct. Each area has Get and Set accessors defined. In either case, the "error information" is passed into the "Set" accessor is a single Tcl_Obj value. The value is documented to be a list made up of option value pairs followed by a string message. This format can be recognized as the return options dictionary converted to a list with the interp result lappended. No public Tcl routine returns error information in this format. This forces the caller of Tcl_SetChannelError(Interp) to do this marshalling for themselves. The one known caller of these routines, Tcl's own reflected channel support, indeed is forced to define two routines MarshallError() and UnmarshallError() to tend to this data formatting task. Seems to me all this complexity can be avoided by just having the Set/Get accessors accept two arguments, one for the interp result, and one for the return options dictionary. (I'm assuming the result code is not required, since these interfaces are intended only for the situation when the code is TCL_ERROR) So the request is to revise these interfaces to take two Tcl_Obj arguments instead of one. In addition, the "safety precaution" described in TIP 219, and implemented as FixLevelCode() is, I believe, completely unnecessary. The -level and -code entries of the return options dictionary only have effect for a result code of TCL_RETURN. Since these interfaces are intended only for result codes of TCL_ERROR, there's no need to worry about them, assuming both sides of handling the bypass areas enforce the TCL_ERROR-only interpretation. | ||||
| User Comments: | ||||
andreas_kupries added on 2006-02-10 02:58:13:
Logged In: YES user_id=75003 Note: Changing the API in this way will _not_ get rid of the (un)marshalling. At least not for the threaded case with the driver (tcl code) and channel residing in different threads. The transfer of the result across threads still requires the conversion to a string and later parsing out the components. What will change is the location of the unmarshalling, it will happen before the Set(Interp|Channel)Error, instead of after Get(Interp|Channel)Error as is done right now. Regarding FixLevelCode I believe to remember that this was the part where I did enforce the restriction of TCL_ERROR. I do know that there is a piece of code converting break, continue, etc. result from the driver Tcl handler into errors. If that conversion alone causes the other parts of the core to ignore -level and -code entries then I will glady get the superfluous parts chucked. dgp added on 2006-02-10 03:06:57:
Logged In: YES user_id=80530 an interp belongs to only one thread, so the bypass area within that interp likewise belongs to only one thread. If we're forced to pass through string reps within the ChannelState struct to deal with passing data between threads, so be it. It should still be easier to convert both message and return options to/from their string rep without having to entangle and disentangle them into/out of one Tcl_Obj. will try to find time to produce a patch. dgp added on 2007-05-01 11:43:04:
Logged In: YES user_id=80530 Originator: YES Just appending a comment so this report will go round the mailing list since several folks are looking at this code again during the valgrind bug hunt. | ||||
