@@ -2827,11 +2827,10 @@ _io_TextIOWrapper_tell_impl(textio *self)
2827
2827
2828
2828
fail :
2829
2829
if (saved_state ) {
2830
- PyObject * type , * value , * traceback ;
2831
- PyErr_Fetch (& type , & value , & traceback );
2830
+ PyObject * exc = PyErr_GetRaisedException ();
2832
2831
res = PyObject_CallMethodOneArg (
2833
2832
self -> decoder , & _Py_ID (setstate ), saved_state );
2834
- _PyErr_ChainExceptions ( type , value , traceback );
2833
+ _PyErr_ChainExceptions1 ( exc );
2835
2834
Py_DECREF (saved_state );
2836
2835
Py_XDECREF (res );
2837
2836
}
@@ -3028,24 +3027,28 @@ _io_TextIOWrapper_close_impl(textio *self)
3028
3027
Py_RETURN_NONE ; /* stream already closed */
3029
3028
}
3030
3029
else {
3031
- PyObject * exc = NULL , * val , * tb ;
3030
+ PyObject * exc = NULL ;
3032
3031
if (self -> finalizing ) {
3033
3032
res = PyObject_CallMethodOneArg (self -> buffer , & _Py_ID (_dealloc_warn ),
3034
3033
(PyObject * )self );
3035
- if (res )
3034
+ if (res ) {
3036
3035
Py_DECREF (res );
3037
- else
3036
+ }
3037
+ else {
3038
3038
PyErr_Clear ();
3039
+ }
3039
3040
}
3040
3041
res = PyObject_CallMethodNoArgs ((PyObject * )self , & _Py_ID (flush ));
3041
- if (res == NULL )
3042
- PyErr_Fetch (& exc , & val , & tb );
3043
- else
3042
+ if (res == NULL ) {
3043
+ exc = PyErr_GetRaisedException ();
3044
+ }
3045
+ else {
3044
3046
Py_DECREF (res );
3047
+ }
3045
3048
3046
3049
res = PyObject_CallMethodNoArgs (self -> buffer , & _Py_ID (close ));
3047
3050
if (exc != NULL ) {
3048
- _PyErr_ChainExceptions (exc , val , tb );
3051
+ _PyErr_ChainExceptions1 (exc );
3049
3052
Py_CLEAR (res );
3050
3053
}
3051
3054
return res ;
0 commit comments