PEP 7: add {...} around null_error() in abstract.c

Issue #27128.
This commit is contained in:
Victor Stinner 2016-08-19 16:59:55 +02:00
parent d042f1f5eb
commit 71aea8e981
1 changed files with 65 additions and 28 deletions

View File

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