@@ -4717,7 +4717,7 @@ static void Admin_background_event_cb (rd_kafka_t *rk, rd_kafka_event_t *rkev,
47174717 PyGILState_STATE gstate ;
47184718 PyObject * error , * method , * ret ;
47194719 PyObject * result = NULL ;
4720- PyObject * exctype = NULL , * exc = NULL , * excargs = NULL ;
4720+ PyObject * exc = NULL , * excargs = NULL ;
47214721
47224722 /* Acquire GIL */
47234723 gstate = PyGILState_Ensure ();
@@ -5093,7 +5093,7 @@ static void Admin_background_event_cb (rd_kafka_t *rk, rd_kafka_event_t *rkev,
50935093 PyObject * trace = NULL ;
50945094
50955095 /* Fetch (and clear) currently raised exception */
5096- PyErr_Fetch ( & exctype , & error , & trace );
5096+ cfl_exception_fetch ( & exc );
50975097 Py_XDECREF (trace );
50985098 }
50995099
@@ -5124,22 +5124,17 @@ static void Admin_background_event_cb (rd_kafka_t *rk, rd_kafka_event_t *rkev,
51245124 * Pass an exception to future.set_exception().
51255125 */
51265126
5127- if (!exctype ) {
5127+ if (!exc ) {
51285128 /* No previous exception raised, use KafkaException */
5129- exctype = KafkaException ;
5130- Py_INCREF (exctype );
5131- }
5132-
5133- /* Create a new exception based on exception type and error. */
5134- excargs = PyTuple_New (1 );
5135- Py_INCREF (error ); /* tuple's reference */
5136- PyTuple_SET_ITEM (excargs , 0 , error );
5137- exc = ((PyTypeObject * )exctype )-> tp_new (
5138- (PyTypeObject * )exctype , NULL , NULL );
5139- exc -> ob_type -> tp_init (exc , excargs , NULL );
5140- Py_DECREF (excargs );
5141- Py_XDECREF (exctype );
5142- Py_XDECREF (error ); /* from error source above */
5129+ excargs = PyTuple_New (1 );
5130+ Py_INCREF (error ); /* tuple's reference */
5131+ PyTuple_SET_ITEM (excargs , 0 , error );
5132+ exc = ((PyTypeObject * )KafkaException )-> tp_new (
5133+ (PyTypeObject * )KafkaException , NULL , NULL );
5134+ exc -> ob_type -> tp_init (exc , excargs , NULL );
5135+ Py_DECREF (excargs );
5136+ Py_XDECREF (error ); /* from error source above */
5137+ }
51435138
51445139 /*
51455140 * Call future.set_exception(exc)
0 commit comments