op->cl_name = name;
if (getattrstr == NULL) {
getattrstr = PyString_InternFromString("__getattr__");
+ if (getattrstr == NULL)
+ return NULL;
setattrstr = PyString_InternFromString("__setattr__");
+ if (setattrstr == NULL)
+ return NULL;
delattrstr = PyString_InternFromString("__delattr__");
+ if (delattrstr == NULL)
+ return NULL;
}
op->cl_getattr = class_lookup(op, getattrstr, &dummy);
op->cl_setattr = class_lookup(op, setattrstr, &dummy);
PyObject *init;
static PyObject *initstr;
+ if (initstr == NULL) {
+ initstr = PyString_InternFromString("__init__");
+ if (initstr == NULL)
+ return NULL;
+ }
inst = (PyInstanceObject *) PyInstance_NewRaw(klass, NULL);
if (inst == NULL)
return NULL;
- if (initstr == NULL)
- initstr = PyString_InternFromString("__init__");
init = instance_getattr2(inst, initstr);
if (init == NULL) {
if (PyErr_Occurred()) {
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
/* Execute __del__ method, if any. */
- if (delstr == NULL)
+ if (delstr == NULL) {
delstr = PyString_InternFromString("__del__");
+ if (delstr == NULL)
+ return NULL;
+ }
if ((del = instance_getattr2(inst, delstr)) != NULL) {
PyObject *res = PyEval_CallObject(del, (PyObject *)NULL);
if (res == NULL)
PyObject *res;
static PyObject *reprstr;
- if (reprstr == NULL)
+ if (reprstr == NULL) {
reprstr = PyString_InternFromString("__repr__");
+ if (reprstr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, reprstr);
if (func == NULL) {
PyObject *classname, *mod;
PyObject *res;
static PyObject *strstr;
- if (strstr == NULL)
+ if (strstr == NULL) {
strstr = PyString_InternFromString("__str__");
+ if (strstr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, strstr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
long outcome;
static PyObject *hashstr, *eqstr, *cmpstr;
- if (hashstr == NULL)
+ if (hashstr == NULL) {
hashstr = PyString_InternFromString("__hash__");
+ if (hashstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, hashstr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
/* If there is no __eq__ and no __cmp__ method, we hash on the
address. If an __eq__ or __cmp__ method exists, there must
be a __hash__. */
- if (eqstr == NULL)
+ if (eqstr == NULL) {
eqstr = PyString_InternFromString("__eq__");
+ if (eqstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, eqstr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
PyErr_Clear();
- if (cmpstr == NULL)
+ if (cmpstr == NULL) {
cmpstr = PyString_InternFromString("__cmp__");
+ if (cmpstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, cmpstr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(
PyObject *res;
Py_ssize_t outcome;
- if (lenstr == NULL)
+ if (lenstr == NULL) {
lenstr = PyString_InternFromString("__len__");
+ if (lenstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, lenstr);
if (func == NULL)
return -1;
PyObject *arg;
PyObject *res;
- if (getitemstr == NULL)
+ if (getitemstr == NULL) {
getitemstr = PyString_InternFromString("__getitem__");
+ if (getitemstr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
PyObject *res;
if (value == NULL) {
- if (delitemstr == NULL)
+ if (delitemstr == NULL) {
delitemstr = PyString_InternFromString("__delitem__");
+ if (delitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, delitemstr);
}
else {
- if (setitemstr == NULL)
+ if (setitemstr == NULL) {
setitemstr = PyString_InternFromString("__setitem__");
+ if (setitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, setitemstr);
}
if (func == NULL)
{
PyObject *func, *res;
- if (getitemstr == NULL)
+ if (getitemstr == NULL) {
getitemstr = PyString_InternFromString("__getitem__");
+ if (getitemstr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
PyObject *func, *arg, *res;
static PyObject *getslicestr;
- if (getslicestr == NULL)
+ if (getslicestr == NULL) {
getslicestr = PyString_InternFromString("__getslice__");
+ if (getslicestr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, getslicestr);
if (func == NULL) {
return NULL;
PyErr_Clear();
- if (getitemstr == NULL)
+ if (getitemstr == NULL) {
getitemstr = PyString_InternFromString("__getitem__");
+ if (getitemstr == NULL)
+ return NULL;
+ }
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
PyObject *func, *arg, *res;
if (item == NULL) {
- if (delitemstr == NULL)
+ if (delitemstr == NULL) {
delitemstr = PyString_InternFromString("__delitem__");
+ if (delitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, delitemstr);
}
else {
- if (setitemstr == NULL)
+ if (setitemstr == NULL) {
setitemstr = PyString_InternFromString("__setitem__");
+ if (setitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, setitemstr);
}
if (func == NULL)
static PyObject *setslicestr, *delslicestr;
if (value == NULL) {
- if (delslicestr == NULL)
+ if (delslicestr == NULL) {
delslicestr =
PyString_InternFromString("__delslice__");
+ if (delslicestr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, delslicestr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
PyErr_Clear();
- if (delitemstr == NULL)
+ if (delitemstr == NULL) {
delitemstr =
PyString_InternFromString("__delitem__");
+ if (delitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, delitemstr);
if (func == NULL)
return -1;
arg = Py_BuildValue("(nn)", i, j);
}
else {
- if (setslicestr == NULL)
+ if (setslicestr == NULL) {
setslicestr =
PyString_InternFromString("__setslice__");
+ if (setslicestr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, setslicestr);
if (func == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
PyErr_Clear();
- if (setitemstr == NULL)
+ if (setitemstr == NULL) {
setitemstr =
PyString_InternFromString("__setitem__");
+ if (setitemstr == NULL)
+ return -1;
+ }
func = instance_getattr(inst, setitemstr);
if (func == NULL)
return -1;
#define UNARY(funcname, methodname) \
static PyObject *funcname(PyInstanceObject *self) { \
static PyObject *o; \
- if (o == NULL) o = PyString_InternFromString(methodname); \
+ if (o == NULL) { o = PyString_InternFromString(methodname); \
+ if (o == NULL) return NULL; } \
return generic_unary_op(self, o); \
}
long outcome;
static PyObject *nonzerostr;
- if (nonzerostr == NULL)
+ if (nonzerostr == NULL) {
nonzerostr = PyString_InternFromString("__nonzero__");
+ if (nonzerostr == NULL)
+ return -1;
+ }
if ((func = instance_getattr(self, nonzerostr)) == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
PyErr_Clear();
- if (lenstr == NULL)
+ if (lenstr == NULL) {
lenstr = PyString_InternFromString("__len__");
+ if (lenstr == NULL)
+ return -1;
+ }
if ((func = instance_getattr(self, lenstr)) == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
{
PyObject *func;
- if (nextstr == NULL)
+ if (nextstr == NULL) {
nextstr = PyString_InternFromString("next");
+ if (nextstr == NULL)
+ return NULL;
+ }
if ((func = instance_getattr(self, nextstr)) != NULL) {
PyObject *res = PyEval_CallObject(func, (PyObject *)NULL);