@@ -174,7 +174,7 @@ static int Admin_set_replica_assignment (const char *forApi, void *c_obj,
174
174
if (!PyList_Check (ra ) ||
175
175
(int )PyList_Size (ra ) < min_count ||
176
176
(int )PyList_Size (ra ) > max_count ) {
177
- PyErr_Format (PyExc_TypeError ,
177
+ PyErr_Format (PyExc_ValueError ,
178
178
"replica_assignment must be "
179
179
"a list of int lists with an "
180
180
"outer size of %s" , err_count_desc );
@@ -192,7 +192,7 @@ static int Admin_set_replica_assignment (const char *forApi, void *c_obj,
192
192
if (!PyList_Check (replicas ) ||
193
193
(replica_cnt = (size_t )PyList_Size (replicas )) < 1 ) {
194
194
PyErr_Format (
195
- PyExc_TypeError ,
195
+ PyExc_ValueError ,
196
196
"replica_assignment must be "
197
197
"a list of int lists with an "
198
198
"outer size of %s" , err_count_desc );
@@ -208,7 +208,7 @@ static int Admin_set_replica_assignment (const char *forApi, void *c_obj,
208
208
209
209
if (!cfl_PyInt_Check (replica )) {
210
210
PyErr_Format (
211
- PyExc_TypeError ,
211
+ PyExc_ValueError ,
212
212
"replica_assignment must be "
213
213
"a list of int lists with an "
214
214
"outer size of %s" , err_count_desc );
@@ -239,7 +239,7 @@ static int Admin_set_replica_assignment (const char *forApi, void *c_obj,
239
239
240
240
if (err ) {
241
241
PyErr_SetString (
242
- PyExc_TypeError , errstr );
242
+ PyExc_ValueError , errstr );
243
243
return 0 ;
244
244
}
245
245
}
@@ -266,7 +266,7 @@ Admin_config_dict_to_c (void *c_obj, PyObject *dict, const char *op_name) {
266
266
rd_kafka_resp_err_t err ;
267
267
268
268
if (!(ks = cfl_PyObject_Unistr (ko ))) {
269
- PyErr_Format (PyExc_TypeError ,
269
+ PyErr_Format (PyExc_ValueError ,
270
270
"expected %s config name to be unicode "
271
271
"string" , op_name );
272
272
return 0 ;
@@ -281,7 +281,7 @@ Admin_config_dict_to_c (void *c_obj, PyObject *dict, const char *op_name) {
281
281
PyObject * vs = NULL , * vs8 = NULL ;
282
282
if (!(vs = cfl_PyObject_Unistr (vo )) ||
283
283
!(v = cfl_PyUnistr_AsUTF8 (vs , & vs8 ))) {
284
- PyErr_Format (PyExc_TypeError ,
284
+ PyErr_Format (PyExc_ValueError ,
285
285
"expect %s config value for %s "
286
286
"to be unicode string" ,
287
287
op_name , k );
@@ -358,7 +358,7 @@ static PyObject *Admin_create_topics (Handle *self, PyObject *args,
358
358
return NULL ;
359
359
360
360
if (!PyList_Check (topics ) || (tcnt = (int )PyList_Size (topics )) < 1 ) {
361
- PyErr_SetString (PyExc_TypeError ,
361
+ PyErr_SetString (PyExc_ValueError ,
362
362
"Expected non-empty list of NewTopic objects" );
363
363
return NULL ;
364
364
}
@@ -392,7 +392,7 @@ static PyObject *Admin_create_topics (Handle *self, PyObject *args,
392
392
if (r == -1 )
393
393
goto err ; /* Exception raised by IsInstance() */
394
394
else if (r == 0 ) {
395
- PyErr_SetString (PyExc_TypeError ,
395
+ PyErr_SetString (PyExc_ValueError ,
396
396
"Expected list of NewTopic objects" );
397
397
goto err ;
398
398
}
@@ -402,7 +402,7 @@ static PyObject *Admin_create_topics (Handle *self, PyObject *args,
402
402
newt -> replication_factor ,
403
403
errstr , sizeof (errstr ));
404
404
if (!c_objs [i ]) {
405
- PyErr_Format (PyExc_TypeError ,
405
+ PyErr_Format (PyExc_ValueError ,
406
406
"Invalid NewTopic(%s): %s" ,
407
407
newt -> topic , errstr );
408
408
i ++ ;
@@ -411,7 +411,7 @@ static PyObject *Admin_create_topics (Handle *self, PyObject *args,
411
411
412
412
if (newt -> replica_assignment ) {
413
413
if (newt -> replication_factor != -1 ) {
414
- PyErr_SetString (PyExc_TypeError ,
414
+ PyErr_SetString (PyExc_ValueError ,
415
415
"replication_factor and "
416
416
"replica_assignment are "
417
417
"mutually exclusive" );
@@ -501,7 +501,7 @@ static PyObject *Admin_delete_topics (Handle *self, PyObject *args,
501
501
return NULL ;
502
502
503
503
if (!PyList_Check (topics ) || (tcnt = (int )PyList_Size (topics )) < 1 ) {
504
- PyErr_SetString (PyExc_TypeError ,
504
+ PyErr_SetString (PyExc_ValueError ,
505
505
"Expected non-empty list of topic strings" );
506
506
return NULL ;
507
507
}
@@ -527,7 +527,7 @@ static PyObject *Admin_delete_topics (Handle *self, PyObject *args,
527
527
528
528
if (topic == Py_None ||
529
529
!(utopic = cfl_PyObject_Unistr (topic ))) {
530
- PyErr_Format (PyExc_TypeError ,
530
+ PyErr_Format (PyExc_ValueError ,
531
531
"Expected list of topic strings, "
532
532
"not %s" ,
533
533
((PyTypeObject * )PyObject_Type (topic ))->
@@ -605,7 +605,7 @@ static PyObject *Admin_create_partitions (Handle *self, PyObject *args,
605
605
return NULL ;
606
606
607
607
if (!PyList_Check (topics ) || (tcnt = (int )PyList_Size (topics )) < 1 ) {
608
- PyErr_SetString (PyExc_TypeError ,
608
+ PyErr_SetString (PyExc_ValueError ,
609
609
"Expected non-empty list of "
610
610
"NewPartitions objects" );
611
611
return NULL ;
@@ -642,7 +642,7 @@ static PyObject *Admin_create_partitions (Handle *self, PyObject *args,
642
642
if (r == -1 )
643
643
goto err ; /* Exception raised by IsInstance() */
644
644
else if (r == 0 ) {
645
- PyErr_SetString (PyExc_TypeError ,
645
+ PyErr_SetString (PyExc_ValueError ,
646
646
"Expected list of "
647
647
"NewPartitions objects" );
648
648
goto err ;
@@ -652,7 +652,7 @@ static PyObject *Admin_create_partitions (Handle *self, PyObject *args,
652
652
newp -> new_total_count ,
653
653
errstr , sizeof (errstr ));
654
654
if (!c_objs [i ]) {
655
- PyErr_Format (PyExc_TypeError ,
655
+ PyErr_Format (PyExc_ValueError ,
656
656
"Invalid NewPartitions(%s): %s" ,
657
657
newp -> topic , errstr );
658
658
goto err ;
@@ -732,7 +732,7 @@ static PyObject *Admin_describe_configs (Handle *self, PyObject *args,
732
732
733
733
if (!PyList_Check (resources ) ||
734
734
(cnt = (int )PyList_Size (resources )) < 1 ) {
735
- PyErr_SetString (PyExc_TypeError ,
735
+ PyErr_SetString (PyExc_ValueError ,
736
736
"Expected non-empty list of ConfigResource "
737
737
"objects" );
738
738
return NULL ;
@@ -775,7 +775,7 @@ static PyObject *Admin_describe_configs (Handle *self, PyObject *args,
775
775
if (r == -1 )
776
776
goto err ; /* Exception raised by IsInstance() */
777
777
else if (r == 0 ) {
778
- PyErr_SetString (PyExc_TypeError ,
778
+ PyErr_SetString (PyExc_ValueError ,
779
779
"Expected list of "
780
780
"ConfigResource objects" );
781
781
goto err ;
@@ -790,7 +790,7 @@ static PyObject *Admin_describe_configs (Handle *self, PyObject *args,
790
790
c_objs [i ] = rd_kafka_ConfigResource_new (
791
791
(rd_kafka_ResourceType_t )restype , resname );
792
792
if (!c_objs [i ]) {
793
- PyErr_Format (PyExc_TypeError ,
793
+ PyErr_Format (PyExc_ValueError ,
794
794
"Invalid ConfigResource(%d,%s)" ,
795
795
restype , resname );
796
796
free (resname );
@@ -871,7 +871,7 @@ static PyObject *Admin_alter_configs (Handle *self, PyObject *args,
871
871
872
872
if (!PyList_Check (resources ) ||
873
873
(cnt = (int )PyList_Size (resources )) < 1 ) {
874
- PyErr_SetString (PyExc_TypeError ,
874
+ PyErr_SetString (PyExc_ValueError ,
875
875
"Expected non-empty list of ConfigResource "
876
876
"objects" );
877
877
return NULL ;
@@ -926,7 +926,7 @@ static PyObject *Admin_alter_configs (Handle *self, PyObject *args,
926
926
if (r == -1 )
927
927
goto err ; /* Exception raised by IsInstance() */
928
928
else if (r == 0 ) {
929
- PyErr_SetString (PyExc_TypeError ,
929
+ PyErr_SetString (PyExc_ValueError ,
930
930
"Expected list of "
931
931
"ConfigResource objects" );
932
932
goto err ;
@@ -941,7 +941,7 @@ static PyObject *Admin_alter_configs (Handle *self, PyObject *args,
941
941
c_objs [i ] = rd_kafka_ConfigResource_new (
942
942
(rd_kafka_ResourceType_t )restype , resname );
943
943
if (!c_objs [i ]) {
944
- PyErr_Format (PyExc_TypeError ,
944
+ PyErr_Format (PyExc_ValueError ,
945
945
"Invalid ConfigResource(%d,%s)" ,
946
946
restype , resname );
947
947
free (resname );
0 commit comments