@@ -1417,23 +1417,24 @@ static igraph_error_t igraphmodule_i_attribute_combine_dicts(PyObject *dict,
14171417 /* Allocate memory for the attribute_combination_records */
14181418 n = PyDict_Size (dict );
14191419 todo = (igraph_attribute_combination_record_t * )calloc (
1420- n + 1 , sizeof (igraph_attribute_combination_record_t )
1420+ n + 1 , sizeof (igraph_attribute_combination_record_t )
14211421 );
14221422 if (todo == 0 ) {
14231423 IGRAPH_ERROR ("cannot allocate memory for attribute combination" , IGRAPH_ENOMEM );
14241424 }
1425- for (i = 0 ; i < n + 1 ; i ++ )
1425+ for (i = 0 ; i < n + 1 ; i ++ ) {
14261426 todo [i ].name = 0 ; /* sentinel elements */
1427+ }
14271428 IGRAPH_FINALLY (igraphmodule_i_free_attribute_combination_records , todo );
14281429
14291430 /* Collect what to do for each attribute in the source dict */
14301431 pos = 0 ; i = 0 ;
14311432 while (PyDict_Next (dict , & pos , & key , & value )) {
14321433 todo [i ].name = PyUnicode_CopyAsString (key );
1433- if (todo [i ].name == 0 )
1434+ if (todo [i ].name == 0 ) {
14341435 IGRAPH_ERROR ("PyUnicode_CopyAsString failed" , IGRAPH_FAILURE );
1435- igraph_attribute_combination_query ( comb , todo [ i ]. name ,
1436- & todo [i ].type , & todo [i ].func );
1436+ }
1437+ IGRAPH_CHECK ( igraph_attribute_combination_query ( comb , todo [ i ]. name , & todo [i ].type , & todo [i ].func ) );
14371438 i ++ ;
14381439 }
14391440
@@ -1564,8 +1565,8 @@ static igraph_error_t igraphmodule_i_attribute_combine_edges(const igraph_t *gra
15641565 PyObject * dict , * newdict ;
15651566
15661567 /* Get the attribute dicts */
1567- dict = ATTR_STRUCT_DICT (graph )[ATTRHASH_IDX_EDGE ];
1568- newdict = ATTR_STRUCT_DICT (newgraph )[ATTRHASH_IDX_EDGE ];
1568+ dict = ATTR_STRUCT_DICT (graph )[ATTRHASH_IDX_EDGE ];
1569+ newdict = ATTR_STRUCT_DICT (newgraph )[ATTRHASH_IDX_EDGE ];
15691570
15701571 return igraphmodule_i_attribute_combine_dicts (dict , newdict ,
15711572 merges , comb );
@@ -1599,13 +1600,13 @@ static igraph_error_t igraphmodule_i_attribute_get_info(const igraph_t *graph,
15991600 if (n ) {
16001601 retval = igraphmodule_PyList_to_existing_strvector_t (keys , n );
16011602 if (retval ) {
1602- return retval ? IGRAPH_FAILURE : IGRAPH_SUCCESS ;
1603+ IGRAPH_ERROR ( "Cannot convert Python list to existing igraph_strvector_t" , IGRAPH_FAILURE ) ;
16031604 }
16041605 }
16051606
16061607 if (t ) {
16071608 k = PyList_Size (keys );
1608- igraph_vector_int_resize (t , k );
1609+ IGRAPH_CHECK ( igraph_vector_int_resize (t , k ) );
16091610 for (j = 0 ; j < k ; j ++ ) {
16101611 int is_numeric = 1 ;
16111612 int is_string = 1 ;
@@ -1763,8 +1764,9 @@ igraph_error_t igraphmodule_i_get_boolean_graph_attr(const igraph_t *graph,
17631764 /* No error checking, if we get here, the type has already been checked by previous
17641765 attribute handler calls... hopefully :) Same applies for the other handlers. */
17651766 o = PyDict_GetItemString (dict , name );
1766- if (!o )
1767+ if (!o ) {
17671768 IGRAPH_ERROR ("No such attribute" , IGRAPH_EINVAL );
1769+ }
17681770 IGRAPH_CHECK (igraph_vector_bool_resize (value , 1 ));
17691771 VECTOR (* value )[0 ] = PyObject_IsTrue (o );
17701772 return IGRAPH_SUCCESS ;
@@ -1778,7 +1780,9 @@ igraph_error_t igraphmodule_i_get_numeric_graph_attr(const igraph_t *graph,
17781780 /* No error checking, if we get here, the type has already been checked by previous
17791781 attribute handler calls... hopefully :) Same applies for the other handlers. */
17801782 o = PyDict_GetItemString (dict , name );
1781- if (!o ) IGRAPH_ERROR ("No such attribute" , IGRAPH_EINVAL );
1783+ if (!o ) {
1784+ IGRAPH_ERROR ("No such attribute" , IGRAPH_EINVAL );
1785+ }
17821786 IGRAPH_CHECK (igraph_vector_resize (value , 1 ));
17831787 if (o == Py_None ) {
17841788 VECTOR (* value )[0 ] = IGRAPH_NAN ;
@@ -1801,8 +1805,9 @@ igraph_error_t igraphmodule_i_get_string_graph_attr(const igraph_t *graph,
18011805
18021806 dict = ATTR_STRUCT_DICT (graph )[ATTRHASH_IDX_GRAPH ];
18031807 o = PyDict_GetItemString (dict , name );
1804- if (!o )
1808+ if (!o ) {
18051809 IGRAPH_ERROR ("No such attribute" , IGRAPH_EINVAL );
1810+ }
18061811 IGRAPH_CHECK (igraph_strvector_resize (value , 1 ));
18071812
18081813 /* For Python 3.x, we simply call PyObject_Str, which produces a
@@ -1815,8 +1820,9 @@ igraph_error_t igraphmodule_i_get_string_graph_attr(const igraph_t *graph,
18151820 Py_INCREF (str );
18161821 } else {
18171822 PyObject * unicode = PyObject_Str (o );
1818- if (unicode == 0 )
1823+ if (unicode == 0 ) {
18191824 IGRAPH_ERROR ("Internal error in PyObject_Str" , IGRAPH_EINVAL );
1825+ }
18201826 str = PyUnicode_AsEncodedString (unicode , "utf-8" , "xmlcharrefreplace" );
18211827 Py_DECREF (unicode );
18221828 }
0 commit comments