Artifacts Associated With Ticket 2140628fffffffffffffffffffffffffffffffff
Ticket change [64f7296383] (rid 92866) by mad_derf on 2008-10-01 16:03:31:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
With the latest Tcl (8.5.4), the errorInfo variable does not seem to be set at tclsh initialisation. The issue being that, if one does : set errorInfo Then we get : can't read "savedErrorInfo": no such variable while executing "set ::errorInfo $savedErrorInfo" In init.tcl (unknown proc) , there are two ways to fix the issue. Either : catch {set $::errorInfo} savedErrorInfo catch {set $::errorCode} savedErrorCode Which will return : can't read "::errorInfo": no such variable When performing the "set errorInfo" The second solution being : if {[info exists ::errorInfo]} { set savedErrorInfo$::errorInfo } else { set savedErrorInfo"" } if {[info exists ::errorInfo]} { set savedErrorCode$::errorCode } else { set savedErrorCode"" } Which seems to be the cleanest one since it keeps the behaviour of Tcl 8.4 Hope this helps DERF - foundin initialized to: "obsolete: 8.5.4"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "mad_derf"
- subsystem initialized to: "07. Variables"
- title initialized to: "errorInfo variable is not set at tclsh init"
- type initialized to: "Bug"
Ticket change [aa99a41ca6] (rid 100952) by dgp on 2008-10-02 02:22:57:
- assignee changed to: "dgp"
- priority changed to: "8"
Ticket change [80d5191a84] (rid 116940) by dgp on 2008-10-02 02:34:26:
- icomment:
Can you describe an actual programming scenario where you want ::errorInfo to have a value before any error has been raised in the interp?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [458ace9317] (rid 99369) by dgp on 2008-10-02 02:43:02:
- closedate changed to: "2008-10-01T19:43:02"
- closer changed to: "dgp"
- icomment:
Looking more carefully, it appears things are working correctly. The variable ::errorInfo holds the stack trace from the most recent error, whether it unwound all the way, or whether a [catch] contained it. In an interactive interp like you are testing, the [history] and auto-loading machinery are active, and the stack trace you see is one created when an error is caught within the workings of [unknown].
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Pending"
- username: "dgp"
Ticket change [3c1c6d7ed1] (rid 120863) by dgp on 2008-10-02 03:40:34:
- icomment:
The init.tcl file in Tcl 8.4 includes the lines: set errorCode "" set errorInfo "" I'm not convinced this is a change that needs "fixing", but if that does end up being desired, the proper fix is just to restore those lines.
- login: "dgp"
- mimetype: "text/plain"
- title changed to: "errorInfo variable is not set at Tcl_Init()"
- username: "dgp"
- icomment:
Ticket change [cc97c343ff] (rid 95727) by dgp on 2008-10-02 03:40:50:
- subsystem changed to: "38. Init - Library - Autoload"
Ticket change [e3b9af2150] (rid 87844) by sf-robot on 2008-10-16 09:21:35:
- closedate changed to: "2008-10-16T02:21:35"
- closer changed to: "sf-robot"
- icomment:
This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
- login: "sf-robot"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "sf-robot"
Ticket change [93d057e682] (rid 105869) by mad_derf on 2008-10-16 14:02:31:
- icomment:
Well, a simple testcase is to start tclsh and issue 'set errorInfo'. At the very least I would get 'can't read errorInfo : no such variable' ... or, to be backward compatible, have the errorInfo set to nothing. But in no case it should report what it reports, this has nothing to do with getting the value of uninitialised errorInfo ...
- login: "mad_derf"
- mimetype: "text/plain"
- username: "mad_derf"
- icomment:
Ticket change [ebb782c05c] (rid 103578) by ferrieux on 2008-10-16 18:22:00:
- icomment:
Don, I think there is a confusion here. While I agree with you that defining a contract for the initial value of errorInfo is uninteresting, a side effect of this report is for us to notice that, within [unknown], the code for saving/restoring errorInfo is ugly. More precisely, that code has the two following behaviors: (1) precond: errorInfo is set; postcond: errorInfo is restored to this value (2) precond: errorInfo is not set; postcond: errorInfo is *set* to the error message internally produced (though caught) when attempting to read it ! (1) is the dominant case, and was also the only case in 8.4 since we never entered [unknown] with errorInfo unset (unless the user typed [unset ::errorInfo] of course) (2) is a more recently exposed case, and is a bug. The fix, by the way, is trivial: --- orig-init.tcl2008-10-16 11:50:31.863767000 +0200 +++ init.tcl2008-10-16 13:20:06.779931000 +0200 @@ -250,9 +250,18 @@ dict incr opts -level return -options $opts $result } - - catch {set savedErrorInfo $::errorInfo} - catch {set savedErrorCode $::errorCode} + if {[info exists ::errorInfo]} { +set savedErrorInfo $::errorInfo +set unsetErrorInfo 0 +} else { +set unsetErrorInfo 1 +} + if {[info exists ::errorCode]} { +set savedErrorCode $::errorCode +set unsetErrorCode 0 +} else { +set unsetErrorCode 1 +} set name $cmd if {![info exists auto_noload]} { # @@ -275,8 +284,8 @@ unset UnknownPending } if {$msg} { - catch {set ::errorCode $savedErrorCode} - catch {set ::errorInfo $savedErrorInfo} + catch {if {$unsetErrorCode} {unset ::errorCode} else {set ::errorCode $savedErrorCode}} + catch {if {$unsetErrorInfo} {unset ::errorInfo} else {set ::errorInfo $savedErrorInfo}} set code [catch {uplevel 1 $args} msg opts] if {$code == 1} { # - login: "ferrieux"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "ferrieux"
- icomment:
Ticket change [71e381a637] (rid 100762) by dgp on 2008-10-16 20:26:59:
- resolution changed to: "Remind"
- title changed to: "[unknown] should leave no tracks"
Ticket change [779a44174e] (rid 89804) by dgp on 2008-10-16 22:36:02:
- icomment:
1063707 is releated. Reading some commit messages, a key constraint why [unknown] must preserve these global variables is that the old [::bgerror] scheme relies on them as a side channel for passing useful information, and in some situations (notably default Tk) the [::bgerror] command is auto-loaded.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [ced9455461] (rid 112853) by ferrieux on 2008-10-16 22:58:37:
- icomment:
The patch previously sent does preserve these globals, and in addition preserves their "unset" state. Do you have objections against applying it ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [c360395348] (rid 111649) by dgp on 2008-10-16 23:09:29:
- closedate changed to: "2008-10-16T16:09:29"
- closer changed to: "dgp"
- icomment:
fixed on HEAD and for 8.5.6.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dgp"
Ticket change [b182f32151] (rid 98159) by mad_derf on 2008-10-16 23:10:07:
- icomment:
*laughing mode on* You're talkin' to me ? *laughing mode off* Well, not sure who the "do *you* have any objections" refers to .. Thanks DERF
- login: "mad_derf"
- mimetype: "text/plain"
- resolution changed to: "Remind"
- status changed to: "Open"
- username: "mad_derf"
- icomment:
Ticket change [292ea8969b] (rid 88831) by ferrieux on 2008-10-16 23:28:17:
- icomment:
Don, while I have to admit your coding style is more elegant than mine, I wonder: In the committed code you unset -nocomplain ... if {...} {set ...} So this means that in the nominal case you always unset-set in a short sequence. I'd have rather put the [unset] in the [else]: if {...} {set ...} else {unset ...} - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [5d0f481e4f] (rid 115392) by dgp on 2008-10-17 00:01:29:
- closedate changed to: "2008-10-16T17:01:29"
- closer changed to: "dgp"
- status changed to: "Closed"