diff options
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 93 |
1 files changed, 65 insertions, 28 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 9e9c9aa..cec47bf 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -32,8 +32,10 @@ PyObject_Type(PyObject *o) { PyObject *v; - if (o == NULL) + if (o == NULL) { return null_error(); + } + v = (PyObject *)o->ob_type; Py_INCREF(v); return v; @@ -137,8 +139,9 @@ PyObject_GetItem(PyObject *o, PyObject *key) { PyMappingMethods *m; - if (o == NULL || key == NULL) + if (o == NULL || key == NULL) { return null_error(); + } m = o->ob_type->tp_as_mapping; if (m && m->mp_subscript) { @@ -1125,8 +1128,10 @@ PyNumber_Negative(PyObject *o) { PyNumberMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } + m = o->ob_type->tp_as_number; if (m && m->nb_negative) return (*m->nb_negative)(o); @@ -1139,8 +1144,10 @@ PyNumber_Positive(PyObject *o) { PyNumberMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } + m = o->ob_type->tp_as_number; if (m && m->nb_positive) return (*m->nb_positive)(o); @@ -1153,8 +1160,10 @@ PyNumber_Invert(PyObject *o) { PyNumberMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } + m = o->ob_type->tp_as_number; if (m && m->nb_invert) return (*m->nb_invert)(o); @@ -1167,8 +1176,10 @@ PyNumber_Absolute(PyObject *o) { PyNumberMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } + m = o->ob_type->tp_as_number; if (m && m->nb_absolute) return m->nb_absolute(o); @@ -1184,8 +1195,10 @@ PyObject * PyNumber_Index(PyObject *item) { PyObject *result = NULL; - if (item == NULL) + if (item == NULL) { return null_error(); + } + if (PyLong_Check(item)) { Py_INCREF(item); return item; @@ -1273,8 +1286,10 @@ PyNumber_Long(PyObject *o) Py_buffer view; _Py_IDENTIFIER(__trunc__); - if (o == NULL) + if (o == NULL) { return null_error(); + } + if (PyLong_CheckExact(o)) { Py_INCREF(o); return o; @@ -1349,8 +1364,10 @@ PyNumber_Float(PyObject *o) { PyNumberMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } + if (PyFloat_CheckExact(o)) { Py_INCREF(o); return o; @@ -1451,8 +1468,9 @@ PySequence_Concat(PyObject *s, PyObject *o) { PySequenceMethods *m; - if (s == NULL || o == NULL) + if (s == NULL || o == NULL) { return null_error(); + } m = s->ob_type->tp_as_sequence; if (m && m->sq_concat) @@ -1475,8 +1493,9 @@ PySequence_Repeat(PyObject *o, Py_ssize_t count) { PySequenceMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } m = o->ob_type->tp_as_sequence; if (m && m->sq_repeat) @@ -1504,8 +1523,9 @@ PySequence_InPlaceConcat(PyObject *s, PyObject *o) { PySequenceMethods *m; - if (s == NULL || o == NULL) + if (s == NULL || o == NULL) { return null_error(); + } m = s->ob_type->tp_as_sequence; if (m && m->sq_inplace_concat) @@ -1528,8 +1548,9 @@ PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count) { PySequenceMethods *m; - if (o == NULL) + if (o == NULL) { return null_error(); + } m = o->ob_type->tp_as_sequence; if (m && m->sq_inplace_repeat) @@ -1557,8 +1578,9 @@ PySequence_GetItem(PyObject *s, Py_ssize_t i) { PySequenceMethods *m; - if (s == NULL) + if (s == NULL) { return null_error(); + } m = s->ob_type->tp_as_sequence; if (m && m->sq_item) { @@ -1583,7 +1605,9 @@ PySequence_GetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2) { PyMappingMethods *mp; - if (!s) return null_error(); + if (!s) { + return null_error(); + } mp = s->ob_type->tp_as_mapping; if (mp && mp->mp_subscript) { @@ -1710,8 +1734,9 @@ PySequence_Tuple(PyObject *v) PyObject *result = NULL; Py_ssize_t j; - if (v == NULL) + if (v == NULL) { return null_error(); + } /* Special-case the common tuple and list cases, for efficiency. */ if (PyTuple_CheckExact(v)) { @@ -1791,8 +1816,9 @@ PySequence_List(PyObject *v) PyObject *result; /* result list */ PyObject *rv; /* return value from PyList_Extend */ - if (v == NULL) + if (v == NULL) { return null_error(); + } result = PyList_New(0); if (result == NULL) @@ -1812,8 +1838,9 @@ PySequence_Fast(PyObject *v, const char *m) { PyObject *it; - if (v == NULL) + if (v == NULL) { return null_error(); + } if (PyList_CheckExact(v) || PyTuple_CheckExact(v)) { Py_INCREF(v); @@ -1996,8 +2023,9 @@ PyMapping_GetItemString(PyObject *o, const char *key) { PyObject *okey, *r; - if (key == NULL) + if (key == NULL) { return null_error(); + } okey = PyUnicode_FromString(key); if (okey == NULL) @@ -2292,8 +2320,9 @@ PyObject_CallFunction(PyObject *callable, const char *format, ...) va_list va; PyObject *args, *result; - if (callable == NULL) + if (callable == NULL) { return null_error(); + } if (format && *format) { va_start(va, format); @@ -2318,8 +2347,9 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...) va_list va; PyObject *args, *result; - if (callable == NULL) + if (callable == NULL) { return null_error(); + } if (format && *format) { va_start(va, format); @@ -2375,8 +2405,9 @@ PyObject_CallMethod(PyObject *o, const char *name, const char *format, ...) PyObject *func = NULL; PyObject *retval = NULL; - if (o == NULL || name == NULL) + if (o == NULL || name == NULL) { return null_error(); + } func = PyObject_GetAttrString(o, name); if (func == NULL) @@ -2397,8 +2428,9 @@ _PyObject_CallMethodId(PyObject *o, _Py_Identifier *name, PyObject *func = NULL; PyObject *retval = NULL; - if (o == NULL || name == NULL) + if (o == NULL || name == NULL) { return null_error(); + } func = _PyObject_GetAttrId(o, name); if (func == NULL) @@ -2419,8 +2451,9 @@ _PyObject_CallMethod_SizeT(PyObject *o, const char *name, PyObject *func = NULL; PyObject *retval; - if (o == NULL || name == NULL) + if (o == NULL || name == NULL) { return null_error(); + } func = PyObject_GetAttrString(o, name); if (func == NULL) @@ -2440,8 +2473,9 @@ _PyObject_CallMethodId_SizeT(PyObject *o, _Py_Identifier *name, PyObject *func = NULL; PyObject *retval; - if (o == NULL || name == NULL) + if (o == NULL || name == NULL) { return null_error(); + } func = _PyObject_GetAttrId(o, name); if (func == NULL) { @@ -2482,8 +2516,9 @@ PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...) PyObject *args, *tmp; va_list vargs; - if (callable == NULL || name == NULL) + if (callable == NULL || name == NULL) { return null_error(); + } callable = PyObject_GetAttr(callable, name); if (callable == NULL) @@ -2511,8 +2546,9 @@ _PyObject_CallMethodIdObjArgs(PyObject *callable, PyObject *args, *tmp; va_list vargs; - if (callable == NULL || name == NULL) + if (callable == NULL || name == NULL) { return null_error(); + } callable = _PyObject_GetAttrId(callable, name); if (callable == NULL) @@ -2539,8 +2575,9 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...) PyObject *args, *tmp; va_list vargs; - if (callable == NULL) + if (callable == NULL) { return null_error(); + } /* count the args */ va_start(vargs, callable); |