X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/9f9ea9ea4df181faa5fa7acadf3a022b25234f3e..f1b0cf0da6b3bcc530d7f72982278510d94f6456:/util.c diff --git a/util.c b/util.c index 4e82ed6..7118bfb 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"); @@ -132,6 +133,7 @@ int convk64(PyObject *o, void *pp) int rc = 0; uint32 lo, hi; + if (!o) VALERR("can't delete"); if (init_i32()) goto end; if ((i = PyNumber_Int(o)) == 0) goto end; lo = PyInt_AsUnsignedLongMask(i); @@ -176,8 +178,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 +228,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);