@@ -43,7 +43,7 @@ type_name(PyTypeObject *type, void *context)
4343
4444 if (type -> tp_flags & Py_TPFLAGS_HEAPTYPE ) {
4545 etype * et = (etype * )type ;
46-
46+
4747 Py_INCREF (et -> name );
4848 return et -> name ;
4949 }
@@ -78,7 +78,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
7878 type -> tp_name , value -> ob_type -> tp_name );
7979 return -1 ;
8080 }
81- if (strlen (PyString_AS_STRING (value ))
81+ if (strlen (PyString_AS_STRING (value ))
8282 != (size_t )PyString_GET_SIZE (value )) {
8383 PyErr_Format (PyExc_ValueError ,
8484 "__name__ must not contain null bytes" );
@@ -310,10 +310,10 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
310310 type -> tp_bases = old_bases ;
311311 type -> tp_base = old_base ;
312312 type -> tp_mro = old_mro ;
313-
313+
314314 Py_DECREF (value );
315315 Py_DECREF (new_base );
316-
316+
317317 return -1 ;
318318}
319319
@@ -884,21 +884,21 @@ classic_mro(PyObject *cls)
884884 return NULL ;
885885}
886886
887- /*
887+ /*
888888 Method resolution order algorithm C3 described in
889889 "A Monotonic Superclass Linearization for Dylan",
890890 by Kim Barrett, Bob Cassel, Paul Haahr,
891- David A. Moon, Keith Playford, and P. Tucker Withington.
891+ David A. Moon, Keith Playford, and P. Tucker Withington.
892892 (OOPSLA 1996)
893893
894894 Some notes about the rules implied by C3:
895895
896- No duplicate bases.
896+ No duplicate bases.
897897 It isn't legal to repeat a class in a list of base classes.
898898
899899 The next three properties are the 3 constraints in "C3".
900900
901- Local precendece order.
901+ Local precendece order.
902902 If A precedes B in C's MRO, then A will precede B in the MRO of all
903903 subclasses of C.
904904
@@ -912,7 +912,7 @@ classic_mro(PyObject *cls)
912912 the paper for definition of EPG.
913913 */
914914
915- static int
915+ static int
916916tail_contains (PyObject * list , int whence , PyObject * o ) {
917917 int j , size ;
918918 size = PyList_GET_SIZE (list );
@@ -1010,12 +1010,12 @@ set_mro_error(PyObject *to_merge, int *remain)
10101010 Py_DECREF (set );
10111011}
10121012
1013- static int
1013+ static int
10141014pmerge (PyObject * acc , PyObject * to_merge ) {
10151015 int i , j , to_merge_size ;
10161016 int * remain ;
10171017 int ok , empty_cnt ;
1018-
1018+
10191019 to_merge_size = PyList_GET_SIZE (to_merge );
10201020
10211021 /* remain stores an index into each sublist of to_merge.
@@ -1032,7 +1032,7 @@ pmerge(PyObject *acc, PyObject* to_merge) {
10321032 empty_cnt = 0 ;
10331033 for (i = 0 ; i < to_merge_size ; i ++ ) {
10341034 PyObject * candidate ;
1035-
1035+
10361036 PyObject * cur_list = PyList_GET_ITEM (to_merge , i );
10371037
10381038 if (remain [i ] >= PyList_GET_SIZE (cur_list )) {
@@ -1092,7 +1092,7 @@ mro_implementation(PyTypeObject *type)
10921092
10931093 /* Find a superclass linearization that honors the constraints
10941094 of the explicit lists of bases and the constraints implied by
1095- each base class.
1095+ each base class.
10961096
10971097 to_merge is a list of lists, where each list is a superclass
10981098 linearization implied by a base class. The last element of
@@ -2288,7 +2288,7 @@ compatible_for_assignment(PyTypeObject* old, PyTypeObject* new, char* attr)
22882288 old -> tp_name );
22892289 return 0 ;
22902290 }
2291-
2291+
22922292 return 1 ;
22932293}
22942294
@@ -2355,7 +2355,7 @@ object_reduce(PyObject *self, PyObject *args)
23552355}
23562356
23572357static PyMethodDef object_methods [] = {
2358- {"__reduce__" , object_reduce , METH_NOARGS ,
2358+ {"__reduce__" , object_reduce , METH_NOARGS ,
23592359 PyDoc_STR ("helper for pickle" )},
23602360 {0 }
23612361};
@@ -3734,30 +3734,29 @@ SLOT0(slot_nb_absolute, "__abs__")
37343734static int
37353735slot_nb_nonzero (PyObject * self )
37363736{
3737- PyObject * func , * res , * args ;
3737+ PyObject * func , * args ;
37383738 static PyObject * nonzero_str , * len_str ;
3739+ int result = -1 ;
37393740
37403741 func = lookup_maybe (self , "__nonzero__" , & nonzero_str );
37413742 if (func == NULL ) {
37423743 if (PyErr_Occurred ())
37433744 return -1 ;
37443745 func = lookup_maybe (self , "__len__" , & len_str );
3745- if (func == NULL ) {
3746- if (PyErr_Occurred ())
3747- return -1 ;
3748- else
3749- return 1 ;
3750- }
3751- }
3752- args = res = PyTuple_New (0 );
3746+ if (func == NULL )
3747+ return PyErr_Occurred () ? -1 : 1 ;
3748+ }
3749+ args = PyTuple_New (0 );
37533750 if (args != NULL ) {
3754- res = PyObject_Call (func , args , NULL );
3751+ PyObject * temp = PyObject_Call (func , args , NULL );
37553752 Py_DECREF (args );
3753+ if (temp != NULL ) {
3754+ result = PyObject_IsTrue (temp );
3755+ Py_DECREF (temp );
3756+ }
37563757 }
37573758 Py_DECREF (func );
3758- if (res == NULL )
3759- return -1 ;
3760- return PyObject_IsTrue (res );
3759+ return result ;
37613760}
37623761
37633762SLOT0 (slot_nb_invert , "__invert__" )
0 commit comments