@@ -23,7 +23,7 @@ Data members:
23
23
#include "pycore_namespace.h" // _PyNamespace_New()
24
24
#include "pycore_object.h" // _PyObject_IS_GC()
25
25
#include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0()
26
- #include "pycore_pyerrors.h" // _PyErr_Fetch ()
26
+ #include "pycore_pyerrors.h" // _PyErr_GetRaisedException ()
27
27
#include "pycore_pylifecycle.h" // _PyErr_WriteUnraisableDefaultHook()
28
28
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
29
29
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
@@ -89,12 +89,11 @@ PySys_GetObject(const char *name)
89
89
{
90
90
PyThreadState * tstate = _PyThreadState_GET ();
91
91
92
- PyObject * exc_type , * exc_value , * exc_tb ;
93
- _PyErr_Fetch (tstate , & exc_type , & exc_value , & exc_tb );
92
+ PyObject * exc = _PyErr_GetRaisedException (tstate );
94
93
PyObject * value = _PySys_GetObject (tstate -> interp , name );
95
94
/* XXX Suppress a new exception if it was raised and restore
96
95
* the old one. */
97
- _PyErr_Restore (tstate , exc_type , exc_value , exc_tb );
96
+ _PyErr_SetRaisedException (tstate , exc );
98
97
return value ;
99
98
}
100
99
@@ -203,8 +202,8 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
203
202
204
203
int dtrace = PyDTrace_AUDIT_ENABLED ();
205
204
206
- PyObject * exc_type , * exc_value , * exc_tb ;
207
- _PyErr_Fetch ( ts , & exc_type , & exc_value , & exc_tb );
205
+
206
+ PyObject * exc = _PyErr_GetRaisedException ( ts );
208
207
209
208
/* Initialize event args now */
210
209
if (argFormat && argFormat [0 ]) {
@@ -287,13 +286,11 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
287
286
Py_XDECREF (eventArgs );
288
287
289
288
if (!res ) {
290
- _PyErr_Restore (ts , exc_type , exc_value , exc_tb );
289
+ _PyErr_SetRaisedException (ts , exc );
291
290
}
292
291
else {
293
292
assert (_PyErr_Occurred (ts ));
294
- Py_XDECREF (exc_type );
295
- Py_XDECREF (exc_value );
296
- Py_XDECREF (exc_tb );
293
+ Py_XDECREF (exc );
297
294
}
298
295
299
296
return res ;
@@ -3661,12 +3658,11 @@ static void
3661
3658
sys_write (PyObject * key , FILE * fp , const char * format , va_list va )
3662
3659
{
3663
3660
PyObject * file ;
3664
- PyObject * error_type , * error_value , * error_traceback ;
3665
3661
char buffer [1001 ];
3666
3662
int written ;
3667
3663
PyThreadState * tstate = _PyThreadState_GET ();
3668
3664
3669
- _PyErr_Fetch ( tstate , & error_type , & error_value , & error_traceback );
3665
+ PyObject * exc = _PyErr_GetRaisedException ( tstate );
3670
3666
file = _PySys_GetAttr (tstate , key );
3671
3667
written = PyOS_vsnprintf (buffer , sizeof (buffer ), format , va );
3672
3668
if (sys_pyfile_write (buffer , file ) != 0 ) {
@@ -3678,7 +3674,7 @@ sys_write(PyObject *key, FILE *fp, const char *format, va_list va)
3678
3674
if (sys_pyfile_write (truncated , file ) != 0 )
3679
3675
fputs (truncated , fp );
3680
3676
}
3681
- _PyErr_Restore (tstate , error_type , error_value , error_traceback );
3677
+ _PyErr_SetRaisedException (tstate , exc );
3682
3678
}
3683
3679
3684
3680
void
@@ -3708,7 +3704,7 @@ sys_format(PyObject *key, FILE *fp, const char *format, va_list va)
3708
3704
const char * utf8 ;
3709
3705
PyThreadState * tstate = _PyThreadState_GET ();
3710
3706
3711
- PyObject * error = _PyErr_GetRaisedException (tstate );
3707
+ PyObject * exc = _PyErr_GetRaisedException (tstate );
3712
3708
file = _PySys_GetAttr (tstate , key );
3713
3709
message = PyUnicode_FromFormatV (format , va );
3714
3710
if (message != NULL ) {
@@ -3720,7 +3716,7 @@ sys_format(PyObject *key, FILE *fp, const char *format, va_list va)
3720
3716
}
3721
3717
Py_DECREF (message );
3722
3718
}
3723
- _PyErr_SetRaisedException (tstate , error );
3719
+ _PyErr_SetRaisedException (tstate , exc );
3724
3720
}
3725
3721
3726
3722
void
0 commit comments