if (PyCArg_CheckExact(value)) {
PyCArgObject *p = (PyCArgObject *)value;
PyObject *ob = p->obj;
+ const char *ob_name;
StgDictObject *dict;
dict = PyType_stgdict(type);
Py_INCREF(value);
return value;
}
+ ob_name = (ob) ? ob->ob_type->tp_name : "???";
PyErr_Format(PyExc_TypeError,
"expected %s instance instead of pointer to %s",
- ((PyTypeObject *)type)->tp_name,
- ob->ob_type->tp_name);
+ ((PyTypeObject *)type)->tp_name, ob_name);
return NULL;
}
#if 1
static int
PointerType_SetProto(StgDictObject *stgdict, PyObject *proto)
{
- if (proto && !PyType_Check(proto)) {
+ if (!proto || !PyType_Check(proto)) {
PyErr_SetString(PyExc_TypeError,
"_type_ must be a type");
return -1;
}
- if (proto && !PyType_stgdict(proto)) {
+ if (!PyType_stgdict(proto)) {
PyErr_SetString(PyExc_TypeError,
"_type_ must have storage info");
return -1;
PyTypeObject *result;
StgDictObject *stgdict;
PyObject *name = PyTuple_GET_ITEM(args, 0);
- PyObject *swapped_args = PyTuple_New(PyTuple_GET_SIZE(args));
+ PyObject *swapped_args;
static PyObject *suffix;
int i;
+ swapped_args = PyTuple_New(PyTuple_GET_SIZE(args));
+ if (!swapped_args)
+ return NULL;
+
if (suffix == NULL)
#ifdef WORDS_BIGENDIAN
suffix = PyString_FromString("_le");
static PyObject *
_build_callargs(CFuncPtrObject *self, PyObject *argtypes,
PyObject *inargs, PyObject *kwds,
- int *poutmask, int *pinoutmask, int *pnumretvals)
+ int *poutmask, int *pinoutmask, unsigned int *pnumretvals)
{
PyObject *paramflags = self->paramflags;
PyObject *callargs;
switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) {
case PARAMFLAG_FIN | PARAMFLAG_FLCID:
/* ['in', 'lcid'] parameter. Always taken from defval */
+ assert(defval);
Py_INCREF(defval);
PyTuple_SET_ITEM(callargs, i, defval);
break;
*/
static PyObject *
_build_result(PyObject *result, PyObject *callargs,
- int outmask, int inoutmask, int numretvals)
+ int outmask, int inoutmask, unsigned int numretvals)
{
- int i, index, bit;
+ unsigned int i, index;
+ int bit;
PyObject *tup = NULL;
if (callargs == NULL)
}
Py_DECREF(result);
+ /* tup will not be allocated if numretvals == 1 */
/* allocate tuple to hold the result */
if (numretvals > 1) {
tup = PyTuple_New(numretvals);
if (!fields) {
PyErr_Clear();
fields = PyTuple_New(0);
+ if (!fields)
+ return -1;
}
if (PyTuple_GET_SIZE(args) > PySequence_Length(fields)) {