Skip to content

Commit 04828ff

Browse files
authored
Merge pull request #885 from wr-web/fix-RC
2 parents 5a451e6 + b91c9ce commit 04828ff

8 files changed

Lines changed: 3 additions & 48 deletions

File tree

src/_igraph/attributes.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ PyObject* igraphmodule_i_create_edge_attribute(const igraph_t* graph,
282282
Py_INCREF(Py_None);
283283
if (PyList_SetItem(values, i, Py_None)) { /* reference stolen */
284284
Py_DECREF(values);
285-
Py_DECREF(Py_None);
286285
return 0;
287286
}
288287
}
@@ -659,7 +658,6 @@ static igraph_error_t igraphmodule_i_attribute_add_vertices(
659658

660659
if (o) {
661660
if (PyList_SetItem(value, i + j, o)) {
662-
Py_DECREF(o); /* append failed */
663661
o = NULL; /* indicate error */
664662
} else {
665663
/* reference stolen by the list */
@@ -721,7 +719,6 @@ static igraph_error_t igraphmodule_i_attribute_permute_vertices(const igraph_t *
721719
Py_INCREF(o);
722720
if (PyList_SetItem(newlist, i, o)) {
723721
PyErr_PrintEx(0);
724-
Py_DECREF(o);
725722
Py_DECREF(newlist);
726723
Py_DECREF(newdict);
727724
IGRAPH_ERROR("", IGRAPH_FAILURE);
@@ -878,7 +875,6 @@ static igraph_error_t igraphmodule_i_attribute_add_edges(
878875

879876
if (o) {
880877
if (PyList_SetItem(value, i + j, o)) {
881-
Py_DECREF(o); /* append failed */
882878
o = NULL; /* indicate error */
883879
} else {
884880
/* reference stolen by the list */
@@ -935,7 +931,6 @@ static igraph_error_t igraphmodule_i_attribute_permute_edges(const igraph_t *gra
935931
Py_INCREF(o);
936932
if (PyList_SetItem(newlist, i, o)) {
937933
PyErr_PrintEx(0);
938-
Py_DECREF(o);
939934
Py_DECREF(newlist);
940935
Py_DECREF(newdict);
941936
IGRAPH_ERROR("", IGRAPH_FAILURE);
@@ -982,7 +977,6 @@ static PyObject* igraphmodule_i_ac_func(PyObject* values,
982977
Py_INCREF(item);
983978

984979
if (PyList_SetItem(list, j, item)) { /* reference to item stolen */
985-
Py_DECREF(item);
986980
Py_DECREF(res);
987981
return 0;
988982
}
@@ -1070,7 +1064,6 @@ static PyObject* igraphmodule_i_ac_sum(PyObject* values,
10701064

10711065
item = PyFloat_FromDouble(sum);
10721066
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1073-
Py_DECREF(item);
10741067
Py_DECREF(res);
10751068
return 0;
10761069
}
@@ -1114,7 +1107,6 @@ static PyObject* igraphmodule_i_ac_prod(PyObject* values,
11141107
/* reference to new float stolen */
11151108
item = PyFloat_FromDouble((double)prod);
11161109
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1117-
Py_DECREF(item);
11181110
Py_DECREF(res);
11191111
return 0;
11201112
}
@@ -1147,7 +1139,6 @@ static PyObject* igraphmodule_i_ac_first(PyObject* values,
11471139

11481140
Py_INCREF(item);
11491141
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1150-
Py_DECREF(item);
11511142
Py_DECREF(res);
11521143
return 0;
11531144
}
@@ -1207,7 +1198,6 @@ static PyObject* igraphmodule_i_ac_random(PyObject* values,
12071198

12081199
Py_INCREF(item);
12091200
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1210-
Py_DECREF(item);
12111201
Py_DECREF(random_func);
12121202
Py_DECREF(res);
12131203
return 0;
@@ -1244,7 +1234,6 @@ static PyObject* igraphmodule_i_ac_last(PyObject* values,
12441234
Py_INCREF(item);
12451235

12461236
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1247-
Py_DECREF(item);
12481237
Py_DECREF(res);
12491238
return 0;
12501239
}
@@ -1290,7 +1279,6 @@ static PyObject* igraphmodule_i_ac_mean(PyObject* values,
12901279
/* reference to new float stolen */
12911280
item = PyFloat_FromDouble((double)mean);
12921281
if (PyList_SetItem(res, i, item)) { /* reference to item stolen */
1293-
Py_DECREF(item);
12941282
Py_DECREF(res);
12951283
return 0;
12961284
}
@@ -1324,7 +1312,6 @@ static PyObject* igraphmodule_i_ac_median(PyObject* values,
13241312

13251313
Py_INCREF(item);
13261314
if (PyList_SetItem(list, j, item)) { /* reference to item stolen */
1327-
Py_DECREF(item);
13281315
Py_DECREF(list);
13291316
Py_DECREF(res);
13301317
return 0;
@@ -1383,7 +1370,6 @@ static PyObject* igraphmodule_i_ac_median(PyObject* values,
13831370

13841371
/* reference to item stolen */
13851372
if (PyList_SetItem(res, i, item)) {
1386-
Py_DECREF(item);
13871373
Py_DECREF(list);
13881374
Py_DECREF(res);
13891375
return 0;

src/_igraph/edgeobject.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ int igraphmodule_Edge_set_attribute(igraphmodule_EdgeObject* self, PyObject* k,
393393
* It took me 1.5 hours between London and Manchester to figure it out */
394394
Py_INCREF(v);
395395
r=PyList_SetItem(result, self->idx, v);
396-
if (r == -1) { Py_DECREF(v); }
397396
return r;
398397
}
399398

@@ -406,15 +405,13 @@ int igraphmodule_Edge_set_attribute(igraphmodule_EdgeObject* self, PyObject* k,
406405
if (i != self->idx) {
407406
Py_INCREF(Py_None);
408407
if (PyList_SetItem(result, i, Py_None) == -1) {
409-
Py_DECREF(Py_None);
410408
Py_DECREF(result);
411409
return -1;
412410
}
413411
} else {
414412
/* Same game with the reference count here */
415413
Py_INCREF(v);
416414
if (PyList_SetItem(result, i, v) == -1) {
417-
Py_DECREF(v);
418415
Py_DECREF(result);
419416
return -1;
420417
}

src/_igraph/edgeseqobject.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ PyObject* igraphmodule_EdgeSeq_get_attribute_values(igraphmodule_EdgeSeqObject*
310310
Py_INCREF(item);
311311

312312
if (PyList_SetItem(result, i, item)) {
313-
Py_DECREF(item);
314313
Py_DECREF(result);
315314
return 0;
316315
}
@@ -335,7 +334,6 @@ PyObject* igraphmodule_EdgeSeq_get_attribute_values(igraphmodule_EdgeSeqObject*
335334
Py_INCREF(item);
336335

337336
if (PyList_SetItem(result, i, item)) {
338-
Py_DECREF(item);
339337
Py_DECREF(result);
340338
return 0;
341339
}
@@ -359,7 +357,6 @@ PyObject* igraphmodule_EdgeSeq_get_attribute_values(igraphmodule_EdgeSeqObject*
359357
Py_INCREF(item);
360358

361359
if (PyList_SetItem(result, i, item)) {
362-
Py_DECREF(item);
363360
Py_DECREF(result);
364361
return 0;
365362
}
@@ -495,7 +492,6 @@ int igraphmodule_EdgeSeq_set_attribute_values_mapping(igraphmodule_EdgeSeqObject
495492
}
496493
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
497494
if (PyList_SetItem(list, i, item)) {
498-
Py_DECREF(item);
499495
return -1;
500496
} /* PyList_SetItem stole a reference to the item automatically */
501497
}
@@ -516,7 +512,6 @@ int igraphmodule_EdgeSeq_set_attribute_values_mapping(igraphmodule_EdgeSeqObject
516512
}
517513
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
518514
if (PyList_SetItem(list, i, item)) {
519-
Py_DECREF(item);
520515
Py_DECREF(list);
521516
return -1;
522517
}
@@ -560,7 +555,6 @@ int igraphmodule_EdgeSeq_set_attribute_values_mapping(igraphmodule_EdgeSeqObject
560555
}
561556
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
562557
if (PyList_SetItem(list, VECTOR(es)[i], item)) {
563-
Py_DECREF(item);
564558
igraph_vector_int_destroy(&es);
565559
return -1;
566560
} /* PyList_SetItem stole a reference to the item automatically */
@@ -579,7 +573,6 @@ int igraphmodule_EdgeSeq_set_attribute_values_mapping(igraphmodule_EdgeSeqObject
579573
for (i = 0; i < n2; i++) {
580574
Py_INCREF(Py_None);
581575
if (PyList_SetItem(list, i, Py_None)) {
582-
Py_DECREF(Py_None);
583576
Py_DECREF(list);
584577
return -1;
585578
}
@@ -596,7 +589,6 @@ int igraphmodule_EdgeSeq_set_attribute_values_mapping(igraphmodule_EdgeSeqObject
596589
}
597590
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
598591
if (PyList_SetItem(list, VECTOR(es)[i], item)) {
599-
Py_DECREF(item);
600592
Py_DECREF(list);
601593
return -1;
602594
}

src/_igraph/indexing.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ static int igraphmodule_i_Graph_adjmatrix_set_index_row(igraph_t* graph,
340340
/* Setting attribute */
341341
Py_INCREF(item);
342342
if (PyList_SetItem(values, eid, item)) {
343-
Py_DECREF(item);
344343
igraph_vector_int_clear(&data->to_add);
345344
}
346345
}
@@ -402,7 +401,6 @@ static int igraphmodule_i_Graph_adjmatrix_set_index_row(igraph_t* graph,
402401
/* Setting attribute */
403402
Py_INCREF(new_value);
404403
if (PyList_SetItem(values, eid, new_value)) {
405-
Py_DECREF(new_value);
406404
igraph_vector_int_clear(&data->to_add);
407405
}
408406
}

src/_igraph/operators.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ PyObject *igraphmodule__union(PyObject *self,
156156
if (!dest || PyList_SetItem(emi, j, dest)) {
157157
igraph_vector_ptr_destroy(&gs);
158158
igraph_vector_int_list_destroy(&edgemaps);
159-
Py_XDECREF(dest);
160159
Py_DECREF(emi);
161160
Py_DECREF(em_list);
162161
return NULL;
@@ -167,7 +166,6 @@ PyObject *igraphmodule__union(PyObject *self,
167166
if (!emi || PyList_SetItem(em_list, i, emi)) {
168167
igraph_vector_ptr_destroy(&gs);
169168
igraph_vector_int_list_destroy(&edgemaps);
170-
Py_XDECREF(emi);
171169
Py_DECREF(em_list);
172170
return NULL;
173171
}
@@ -281,7 +279,6 @@ PyObject *igraphmodule__intersection(PyObject *self,
281279
if (!dest || PyList_SetItem(emi, j, dest)) {
282280
igraph_vector_ptr_destroy(&gs);
283281
igraph_vector_int_list_destroy(&edgemaps);
284-
Py_XDECREF(dest);
285282
Py_DECREF(emi);
286283
Py_DECREF(em_list);
287284
return NULL;
@@ -292,7 +289,6 @@ PyObject *igraphmodule__intersection(PyObject *self,
292289
if (!emi || PyList_SetItem(em_list, i, emi)) {
293290
igraph_vector_ptr_destroy(&gs);
294291
igraph_vector_int_list_destroy(&edgemaps);
295-
Py_XDECREF(emi);
296292
Py_DECREF(em_list);
297293
return NULL;
298294
}

src/_igraph/pyhelpers.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ PyObject* igraphmodule_PyList_NewFill(Py_ssize_t len, PyObject* item) {
8484
for (i = 0; i < len; i++) {
8585
Py_INCREF(item);
8686
if (PyList_SetItem(result, i, item)) {
87-
Py_DECREF(item);
88-
Py_DECREF(result);
89-
return 0;
90-
}
87+
Py_DECREF(result);
88+
return 0;
89+
}
9190
}
9291

9392
return result;

src/_igraph/vertexobject.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ int igraphmodule_Vertex_set_attribute(igraphmodule_VertexObject* self, PyObject*
524524
* It took me 1.5 hours between London and Manchester to figure it out */
525525
Py_INCREF(v);
526526
r=PyList_SetItem(result, self->idx, v);
527-
if (r == -1) { Py_DECREF(v); }
528527
return r;
529528
}
530529

@@ -537,15 +536,13 @@ int igraphmodule_Vertex_set_attribute(igraphmodule_VertexObject* self, PyObject*
537536
if (i != self->idx) {
538537
Py_INCREF(Py_None);
539538
if (PyList_SetItem(result, i, Py_None) == -1) {
540-
Py_DECREF(Py_None);
541539
Py_DECREF(result);
542540
return -1;
543541
}
544542
} else {
545543
/* Same game with the reference count here */
546544
Py_INCREF(v);
547545
if (PyList_SetItem(result, i, v) == -1) {
548-
Py_DECREF(v);
549546
Py_DECREF(result);
550547
return -1;
551548
}
@@ -639,7 +636,6 @@ static PyObject* _convert_to_edge_list(igraphmodule_VertexObject* vertex, PyObje
639636
}
640637

641638
if (PyList_SetItem(obj, i, edge)) { /* reference to v stolen, reference to idx discarded */
642-
Py_DECREF(edge);
643639
return NULL;
644640
}
645641
}
@@ -684,7 +680,6 @@ static PyObject* _convert_to_vertex_list(igraphmodule_VertexObject* vertex, PyOb
684680
}
685681

686682
if (PyList_SetItem(obj, i, v)) { /* reference to v stolen, reference to idx discarded */
687-
Py_DECREF(v);
688683
return NULL;
689684
}
690685
}

src/_igraph/vertexseqobject.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ PyObject* igraphmodule_VertexSeq_get_attribute_values(igraphmodule_VertexSeqObje
295295
Py_INCREF(item);
296296

297297
if (PyList_SetItem(result, i, item)) {
298-
Py_DECREF(item);
299298
Py_DECREF(result);
300299
return 0;
301300
}
@@ -320,7 +319,6 @@ PyObject* igraphmodule_VertexSeq_get_attribute_values(igraphmodule_VertexSeqObje
320319
Py_INCREF(item);
321320

322321
if (PyList_SetItem(result, i, item)) {
323-
Py_DECREF(item);
324322
Py_DECREF(result);
325323
return 0;
326324
}
@@ -343,7 +341,6 @@ PyObject* igraphmodule_VertexSeq_get_attribute_values(igraphmodule_VertexSeqObje
343341
Py_INCREF(item);
344342

345343
if (PyList_SetItem(result, i, item)) {
346-
Py_DECREF(item);
347344
Py_DECREF(result);
348345
return 0;
349346
}
@@ -469,7 +466,6 @@ int igraphmodule_VertexSeq_set_attribute_values_mapping(igraphmodule_VertexSeqOb
469466
if (item == 0) return -1;
470467
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
471468
if (PyList_SetItem(list, i, item)) {
472-
Py_DECREF(item);
473469
return -1;
474470
} /* PyList_SetItem stole a reference to the item automatically */
475471
}
@@ -487,7 +483,6 @@ int igraphmodule_VertexSeq_set_attribute_values_mapping(igraphmodule_VertexSeqOb
487483
}
488484
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
489485
if (PyList_SetItem(list, i, item)) {
490-
Py_DECREF(item);
491486
Py_DECREF(list);
492487
return -1;
493488
}
@@ -530,7 +525,6 @@ int igraphmodule_VertexSeq_set_attribute_values_mapping(igraphmodule_VertexSeqOb
530525
}
531526
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
532527
if (PyList_SetItem(list, VECTOR(vs)[i], item)) {
533-
Py_DECREF(item);
534528
igraph_vector_int_destroy(&vs);
535529
return -1;
536530
} /* PyList_SetItem stole a reference to the item automatically */
@@ -549,7 +543,6 @@ int igraphmodule_VertexSeq_set_attribute_values_mapping(igraphmodule_VertexSeqOb
549543
for (i = 0; i < n2; i++) {
550544
Py_INCREF(Py_None);
551545
if (PyList_SetItem(list, i, Py_None)) {
552-
Py_DECREF(Py_None);
553546
Py_DECREF(list);
554547
igraph_vector_int_destroy(&vs);
555548
return -1;
@@ -566,7 +559,6 @@ int igraphmodule_VertexSeq_set_attribute_values_mapping(igraphmodule_VertexSeqOb
566559
}
567560
/* No need to Py_INCREF(item), PySequence_GetItem returns a new reference */
568561
if (PyList_SetItem(list, VECTOR(vs)[i], item)) {
569-
Py_DECREF(list);
570562
Py_DECREF(item);
571563
igraph_vector_int_destroy(&vs);
572564
return -1;

0 commit comments

Comments
 (0)