X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/1b6734b68d788a57b9491360a3ca8dfebeae60bc..c5d395fadbfd59e0744953042acfd6a5b56db919:/util.c diff --git a/util.c b/util.c index 4e82ed6..d4b7fb0 100644 --- a/util.c +++ b/util.c @@ -83,6 +83,7 @@ int convulong(PyObject *o, void *pp) unsigned long *p = pp; PyObject *t; + if (!o) VALERR("can't delete"); if (PyInt_Check(o)) { i = PyInt_AS_LONG(o); if (i < 0) VALERR("must be nonnegative"); @@ -176,8 +177,11 @@ end: int convbool(PyObject *o, void *pp) { + if (!o) VALERR("can't delete"); *(int *)pp = PyObject_IsTrue(o); return (1); +end: + return (0); } /*----- Type messing ------------------------------------------------------*/ @@ -223,9 +227,9 @@ void typeready(PyTypeObject *ty) PyDict_SetItemString(ty->tp_dict, "__module__", modname); } -PyTypeObject *inittype(PyTypeObject *tyskel) +PyTypeObject *inittype(PyTypeObject *tyskel, PyTypeObject *meta) { - PyTypeObject *ty = newtype(&PyType_Type, tyskel, 0); + PyTypeObject *ty = newtype(meta, tyskel, 0); ty->tp_flags |= Py_TPFLAGS_HEAPTYPE; typeready(ty); return (ty);