summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--generic/tclEvent.c46
-rw-r--r--generic/tclResult.c13
-rw-r--r--tests/init.test4
4 files changed, 37 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c18ed7..c371417 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2007-09-06 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclResult.c (Tcl_GetReturnOptions): Take care that a
+ * tests/init.test: non-TCL_ERROR code doesn't cause existing
+ -errorinfo, -errorcode, and -errorline entries to be omitted.
+ * generic/tclEvent.c: With -errorInfo no longer lost, generate more
+ complete ::errorInfo when calling [bgerror] after a non-TCL_ERROR
+ background exception.
+
+2007-09-06 Don Porter <dgp@users.sourceforge.net>
+
* generic/tclInterp.c (Tcl_Init): Removed constraint on ability
to define a custom [tclInit] before calling Tcl_Init(). Until now
the custom command had to be a proc. Now it can be any command.
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 4b37b1e..78b44c2 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEvent.c,v 1.74 2007/09/06 18:13:19 dgp Exp $
+ * RCS: @(#) $Id: tclEvent.c,v 1.75 2007/09/07 15:51:25 dgp Exp $
*/
#include "tclInt.h"
@@ -356,35 +356,29 @@ TclDefaultBgErrorHandlerObjCmd(
tempObjv[1] = Tcl_ObjPrintf("command returned bad code: %d", code);
break;
}
- if (code == TCL_ERROR) {
- /*
- * Restore important state variables to what they were at the time
- * the error occurred.
- *
- * Need to set the variables, not the interp fields, because
- * Tcl_EvalObjv calls Tcl_ResetResult which would destroy
- * anything we write to the interp fields.
- */
+ Tcl_IncrRefCount(tempObjv[1]);
- TclNewLiteralStringObj(keyPtr, "-errorcode");
- Tcl_IncrRefCount(keyPtr);
- Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
- if (valuePtr) {
- Tcl_SetVar2Ex(interp, "errorCode", NULL, valuePtr, TCL_GLOBAL_ONLY);
- }
+ TclNewLiteralStringObj(keyPtr, "-errorcode");
+ Tcl_IncrRefCount(keyPtr);
+ Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
+ Tcl_DecrRefCount(keyPtr);
+ if (valuePtr) {
+ Tcl_SetObjErrorCode(interp, valuePtr);
+ }
- TclNewLiteralStringObj(keyPtr, "-errorinfo");
- Tcl_IncrRefCount(keyPtr);
- Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
- Tcl_DecrRefCount(keyPtr);
- if (valuePtr) {
- Tcl_SetVar2Ex(interp, "errorInfo", NULL, valuePtr, TCL_GLOBAL_ONLY);
+ TclNewLiteralStringObj(keyPtr, "-errorinfo");
+ Tcl_IncrRefCount(keyPtr);
+ Tcl_DictObjGet(NULL, objv[2], keyPtr, &valuePtr);
+ Tcl_DecrRefCount(keyPtr);
+ if (valuePtr) {
+ if (code != TCL_ERROR) {
+ Tcl_SetObjResult(interp, tempObjv[1]);
}
- } else {
- Tcl_AppendObjToErrorInfo(interp, Tcl_DuplicateObj(tempObjv[1]));
+ Tcl_IncrRefCount(valuePtr);
+ Tcl_AppendObjToErrorInfo(interp, valuePtr);
}
- Tcl_IncrRefCount(tempObjv[1]);
+
+ /* Capture stack trace now, so we can report it if [bgerror] fails. */
valuePtr = Tcl_GetVar2Ex(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
Tcl_IncrRefCount(valuePtr);
diff --git a/generic/tclResult.c b/generic/tclResult.c
index c77e634..64be014 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclResult.c,v 1.37 2007/06/05 17:57:08 dgp Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.38 2007/09/07 15:51:26 dgp Exp $
*/
#include "tclInt.h"
@@ -1452,14 +1452,13 @@ Tcl_GetReturnOptions(
}
if (result == TCL_ERROR) {
- /*
- * When result was an error, fill in any missing values for
- * -errorinfo, -errorcode, and -errorline.
- */
-
Tcl_AddObjErrorInfo(interp, "", -1);
- Tcl_DictObjPut(NULL, options, keys[KEY_ERRORINFO], iPtr->errorInfo);
+ }
+ if (iPtr->errorCode) {
Tcl_DictObjPut(NULL, options, keys[KEY_ERRORCODE], iPtr->errorCode);
+ }
+ if (iPtr->errorInfo) {
+ Tcl_DictObjPut(NULL, options, keys[KEY_ERRORINFO], iPtr->errorInfo);
Tcl_DictObjPut(NULL, options, keys[KEY_ERRORLINE],
Tcl_NewIntObj(iPtr->errorLine));
}
diff --git a/tests/init.test b/tests/init.test
index da94d67..520a731 100644
--- a/tests/init.test
+++ b/tests/init.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: init.test,v 1.15 2006/11/03 00:34:52 hobbs Exp $
+# RCS: @(#) $Id: init.test,v 1.16 2007/09/07 15:51:26 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -207,7 +207,7 @@ test init-5.0 {return options passed through ::unknown} -setup {
list $code $foo $bar $code2 $foo2 $bar2
} -cleanup {
unset ::auto_index(::xxx)
-} -result {2 xxx {-code 1 -level 1} 2 xxx {-code 1 -level 1}}
+} -result {2 xxx {-code 1 -level 1 -errorcode NONE} 2 xxx {-code 1 -level 1 -errorcode NONE}}
cleanupTests
} ;# End of [interp eval $testInterp]