@@ -321,8 +321,6 @@ static PyObject *Tkinter_TclError;
321
321
static int quitMainLoop = 0 ;
322
322
static int errorInCmd = 0 ;
323
323
static PyObject * excInCmd ;
324
- static PyObject * valInCmd ;
325
- static PyObject * trbInCmd ;
326
324
327
325
#ifdef TKINTER_PROTECT_LOADTK
328
326
static int tk_load_failed = 0 ;
@@ -1222,7 +1220,7 @@ typedef struct Tkapp_CallEvent {
1222
1220
PyObject * args ;
1223
1221
int flags ;
1224
1222
PyObject * * res ;
1225
- PyObject * * exc_type , * * exc_value , * * exc_tb ;
1223
+ PyObject * * exc ;
1226
1224
Tcl_Condition * done ;
1227
1225
} Tkapp_CallEvent ;
1228
1226
@@ -1339,7 +1337,7 @@ Tkapp_CallProc(Tkapp_CallEvent *e, int flags)
1339
1337
ENTER_PYTHON
1340
1338
objv = Tkapp_CallArgs (e -> args , objStore , & objc );
1341
1339
if (!objv ) {
1342
- PyErr_Fetch (e -> exc_type , e -> exc_value , e -> exc_tb );
1340
+ * (e -> exc ) = PyErr_GetRaisedException ( );
1343
1341
* (e -> res ) = NULL ;
1344
1342
}
1345
1343
LEAVE_PYTHON
@@ -1354,7 +1352,7 @@ Tkapp_CallProc(Tkapp_CallEvent *e, int flags)
1354
1352
* (e -> res ) = Tkapp_ObjectResult (e -> self );
1355
1353
}
1356
1354
if (* (e -> res ) == NULL ) {
1357
- PyErr_Fetch (e -> exc_type , e -> exc_value , e -> exc_tb );
1355
+ * (e -> exc ) = PyErr_GetRaisedException ( );
1358
1356
}
1359
1357
LEAVE_PYTHON
1360
1358
@@ -1401,7 +1399,7 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
1401
1399
marshal the parameters to the interpreter thread. */
1402
1400
Tkapp_CallEvent * ev ;
1403
1401
Tcl_Condition cond = NULL ;
1404
- PyObject * exc_type , * exc_value , * exc_tb ;
1402
+ PyObject * exc ;
1405
1403
if (!WaitForMainloop (self ))
1406
1404
return NULL ;
1407
1405
ev = (Tkapp_CallEvent * )attemptckalloc (sizeof (Tkapp_CallEvent ));
@@ -1413,18 +1411,18 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
1413
1411
ev -> self = self ;
1414
1412
ev -> args = args ;
1415
1413
ev -> res = & res ;
1416
- ev -> exc_type = & exc_type ;
1417
- ev -> exc_value = & exc_value ;
1418
- ev -> exc_tb = & exc_tb ;
1414
+ ev -> exc = & exc ;
1419
1415
ev -> done = & cond ;
1420
1416
1421
1417
Tkapp_ThreadSend (self , (Tcl_Event * )ev , & cond , & call_mutex );
1422
1418
1423
1419
if (res == NULL ) {
1424
- if (exc_type )
1425
- PyErr_Restore (exc_type , exc_value , exc_tb );
1426
- else
1427
- PyErr_SetObject (Tkinter_TclError , exc_value );
1420
+ if (exc ) {
1421
+ PyErr_SetRaisedException (exc );
1422
+ }
1423
+ else {
1424
+ PyErr_SetObject (Tkinter_TclError , exc );
1425
+ }
1428
1426
}
1429
1427
Tcl_ConditionFinalize (& cond );
1430
1428
}
@@ -1578,8 +1576,7 @@ typedef struct VarEvent {
1578
1576
int flags ;
1579
1577
EventFunc func ;
1580
1578
PyObject * * res ;
1581
- PyObject * * exc_type ;
1582
- PyObject * * exc_val ;
1579
+ PyObject * * exc ;
1583
1580
Tcl_Condition * cond ;
1584
1581
} VarEvent ;
1585
1582
@@ -1643,12 +1640,7 @@ var_perform(VarEvent *ev)
1643
1640
{
1644
1641
* (ev -> res ) = ev -> func (ev -> self , ev -> args , ev -> flags );
1645
1642
if (!* (ev -> res )) {
1646
- PyObject * exc , * val , * tb ;
1647
- PyErr_Fetch (& exc , & val , & tb );
1648
- PyErr_NormalizeException (& exc , & val , & tb );
1649
- * (ev -> exc_type ) = exc ;
1650
- * (ev -> exc_val ) = val ;
1651
- Py_XDECREF (tb );
1643
+ * (ev -> exc ) = PyErr_GetRaisedException ();;
1652
1644
}
1653
1645
1654
1646
}
@@ -1672,7 +1664,7 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
1672
1664
TkappObject * self = (TkappObject * )selfptr ;
1673
1665
if (self -> threaded && self -> thread_id != Tcl_GetCurrentThread ()) {
1674
1666
VarEvent * ev ;
1675
- PyObject * res , * exc_type , * exc_val ;
1667
+ PyObject * res , * exc ;
1676
1668
Tcl_Condition cond = NULL ;
1677
1669
1678
1670
/* The current thread is not the interpreter thread. Marshal
@@ -1691,16 +1683,14 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
1691
1683
ev -> flags = flags ;
1692
1684
ev -> func = func ;
1693
1685
ev -> res = & res ;
1694
- ev -> exc_type = & exc_type ;
1695
- ev -> exc_val = & exc_val ;
1686
+ ev -> exc = & exc ;
1696
1687
ev -> cond = & cond ;
1697
1688
ev -> ev .proc = (Tcl_EventProc * )var_proc ;
1698
1689
Tkapp_ThreadSend (self , (Tcl_Event * )ev , & cond , & var_mutex );
1699
1690
Tcl_ConditionFinalize (& cond );
1700
1691
if (!res ) {
1701
- PyErr_SetObject (exc_type , exc_val );
1702
- Py_DECREF (exc_type );
1703
- Py_DECREF (exc_val );
1692
+ PyErr_SetObject (Py_TYPE (exc ), exc );
1693
+ Py_DECREF (exc );
1704
1694
return NULL ;
1705
1695
}
1706
1696
return res ;
@@ -2188,7 +2178,7 @@ static int
2188
2178
PythonCmd_Error (Tcl_Interp * interp )
2189
2179
{
2190
2180
errorInCmd = 1 ;
2191
- PyErr_Fetch ( & excInCmd , & valInCmd , & trbInCmd );
2181
+ excInCmd = PyErr_GetRaisedException ( );
2192
2182
LEAVE_PYTHON
2193
2183
return TCL_ERROR ;
2194
2184
}
@@ -2458,7 +2448,7 @@ FileHandler(ClientData clientData, int mask)
2458
2448
res = PyObject_CallFunction (func , "Oi" , file , mask );
2459
2449
if (res == NULL ) {
2460
2450
errorInCmd = 1 ;
2461
- PyErr_Fetch ( & excInCmd , & valInCmd , & trbInCmd );
2451
+ excInCmd = PyErr_GetRaisedException ( );
2462
2452
}
2463
2453
Py_XDECREF (res );
2464
2454
LEAVE_PYTHON
@@ -2628,7 +2618,7 @@ TimerHandler(ClientData clientData)
2628
2618
2629
2619
if (res == NULL ) {
2630
2620
errorInCmd = 1 ;
2631
- PyErr_Fetch ( & excInCmd , & valInCmd , & trbInCmd );
2621
+ excInCmd = PyErr_GetRaisedException ( );
2632
2622
}
2633
2623
else
2634
2624
Py_DECREF (res );
@@ -2725,7 +2715,7 @@ _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
2725
2715
2726
2716
if (errorInCmd ) {
2727
2717
errorInCmd = 0 ;
2728
- PyErr_Restore (excInCmd , valInCmd , trbInCmd );
2718
+ PyErr_SetRaisedException (excInCmd );
2729
2719
excInCmd = valInCmd = trbInCmd = NULL ;
2730
2720
return NULL ;
2731
2721
}
@@ -3187,8 +3177,8 @@ EventHook(void)
3187
3177
#endif
3188
3178
if (errorInCmd ) {
3189
3179
errorInCmd = 0 ;
3190
- PyErr_Restore (excInCmd , valInCmd , trbInCmd );
3191
- excInCmd = valInCmd = trbInCmd = NULL ;
3180
+ PyErr_SetRaisedException (excInCmd );
3181
+ excInCmd = NULL ;
3192
3182
PyErr_Print ();
3193
3183
}
3194
3184
PyEval_SaveThread ();
0 commit comments