Skip to content

Commit 631eb9b

Browse files
committed
Handle None error_cb and dr_cb
1 parent e92ae7c commit 631eb9b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

confluent_kafka/src/Producer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ static PyObject *Producer_produce (Handle *self, PyObject *args,
280280
return NULL;
281281
}
282282

283-
if (!dr_cb)
283+
if (!dr_cb || dr_cb == Py_None)
284284
dr_cb = self->u.Producer.default_dr_cb;
285-
if (!partitioner_cb)
285+
if (!partitioner_cb || partitioner_cb == Py_None)
286286
partitioner_cb = self->u.Producer.partitioner_cb;
287287

288288
/* Create msgstate if necessary, may return NULL if no callbacks

confluent_kafka/src/confluent_kafka.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,14 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
11131113
continue;
11141114

11151115
} else if (!strcmp(k, "error_cb")) {
1116-
if (h->error_cb)
1116+
if (h->error_cb) {
11171117
Py_DECREF(h->error_cb);
1118-
h->error_cb = vo;
1119-
Py_INCREF(h->error_cb);
1118+
h->error_cb = NULL;
1119+
}
1120+
if (vo != Py_None) {
1121+
h->error_cb = vo;
1122+
Py_INCREF(h->error_cb);
1123+
}
11201124
Py_DECREF(ks);
11211125
continue;
11221126
}

0 commit comments

Comments
 (0)