catacomb-python.h: Add a macro for raising `OverflowError'.
[catacomb-python] / key.c
diff --git a/key.c b/key.c
index dff59ec..4995035 100644 (file)
--- a/key.c
+++ b/key.c
@@ -38,27 +38,25 @@ static PyObject *kxmeth___init__(PyObject *me, PyObject *arg)
 {
   int err;
   PyObject *x = 0;
+  Py_ssize_t n;
 
+  n = PyTuple_GET_SIZE(arg);
   if (!PyArg_ParseTuple(arg, "Oi:__init__", &me, &err) ||
       (x = PyInt_FromLong(err)) == 0 ||
       PyObject_SetAttrString(me, "err", x))
-    goto fail;
-  Py_DECREF(x); x = 0;
-  if ((x = PyString_FromString(key_strerror(err))) == 0 ||
-      PyObject_SetAttrString(me, "errstring", x))
-    goto fail;
+    goto end;
   Py_DECREF(x); x = 0;
   if ((x = PyString_FromString(key_strerror(err))) == 0 ||
       PyObject_SetAttrString(me, "errstring", x))
-    goto fail;
+    goto end;
   Py_DECREF(x); x = 0;
-  if ((x = PySequence_GetSlice(arg, 1, PySequence_Size(arg))) == 0 ||
+  if ((x = PyTuple_GetSlice(arg, 1, n)) == 0 ||
       PyObject_SetAttrString(me, "args", x))
-    goto fail;
+    goto end;
   Py_DECREF(x); x = 0;
   RETURN_NONE;
 
-fail:
+end:
   Py_XDECREF(x);
   return (0);
 }
@@ -104,7 +102,7 @@ static PyMethodDef keyexc_pymethods[] = {
 
 static void keyexc_raise(int err)
 {
-  PyObject *arg = Py_BuildValue("(is)", err, key_strerror(err));
+  PyObject *arg = Py_BuildValue("(i)", err);
   if (arg) PyErr_SetObject(keyexc, arg);
   Py_XDECREF(arg);
 }