chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
debian/changelog: Prepare for the next version.
[catacomb-python]
/
util.c
diff --git
a/util.c
b/util.c
index 4e82ed628e218ef7e0ec6a34140db7a1400645e4..2e6ee258db18d622c549bd209bf95d9fc2143ebc 100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-83,6
+83,7
@@
int convulong(PyObject *o, void *pp)
unsigned long *p = pp;
PyObject *t;
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");
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;
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);
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)
{
int convbool(PyObject *o, void *pp)
{
+ if (!o) VALERR("can't delete");
*(int *)pp = PyObject_IsTrue(o);
return (1);
*(int *)pp = PyObject_IsTrue(o);
return (1);
+end:
+ return (0);
}
/*----- Type messing ------------------------------------------------------*/
}
/*----- Type messing ------------------------------------------------------*/
@@
-223,9
+228,9
@@
void typeready(PyTypeObject *ty)
PyDict_SetItemString(ty->tp_dict, "__module__", modname);
}
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);
ty->tp_flags |= Py_TPFLAGS_HEAPTYPE;
typeready(ty);
return (ty);
@@
-598,13
+603,15
@@
end:
return (rc);
}
return (rc);
}
-static c
har *
def_kwlist[] = { "key", "default", 0 };
+static c
onst char *const
def_kwlist[] = { "key", "default", 0 };
PyObject *gmapmeth_get(PyObject *me, PyObject *arg, PyObject *kw)
{
PyObject *k, *def = Py_None, *v;
PyObject *gmapmeth_get(PyObject *me, PyObject *arg, PyObject *kw)
{
PyObject *k, *def = Py_None, *v;
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:get", def_kwlist, &k, &def))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:get",
+ (/*unconst*/ char **)def_kwlist,
+ &k, &def))
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) return (v);
PyErr_Clear();
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) return (v);
PyErr_Clear();
@@
-616,7
+623,8
@@
PyObject *gmapmeth_setdefault(PyObject *me, PyObject *arg, PyObject *kw)
PyObject *k, *def = Py_None, *v;
if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:setdefault",
PyObject *k, *def = Py_None, *v;
if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:setdefault",
- def_kwlist, &k, &def))
+ (/*unconst*/ char **)def_kwlist,
+ &k, &def))
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) return (v);
PyErr_Clear();
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) return (v);
PyErr_Clear();
@@
-628,7
+636,9
@@
PyObject *gmapmeth_pop(PyObject *me, PyObject *arg, PyObject *kw)
{
PyObject *k, *def = 0, *v;
{
PyObject *k, *def = 0, *v;
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:pop", def_kwlist, &k, &def))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:pop",
+ (/*unconst*/ char **)def_kwlist,
+ &k, &def))
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) {
PyObject_DelItem(me, k);
return (0);
if ((v = PyObject_GetItem(me, k)) != 0) {
PyObject_DelItem(me, k);