catacomb.c: Use a less awful version comparison.
[pyke] / catacomb.c
index e9c9513..b54227f 100644 (file)
@@ -74,8 +74,8 @@ PyObject *mexp_common(PyObject *me, PyObject *arg,
   PyObject *qq, *x, *y, *z = 0;
   char *v = 0, *vv;
 
-  if (PyTuple_Size(arg) == 1)
-    arg = PyTuple_GetItem(arg, 0);
+  if (PyTuple_GET_SIZE(arg) == 1)
+    arg = PyTuple_GET_ITEM(arg, 0);
   Py_INCREF(arg);
   if (!PySequence_Check(arg)) TYERR("not a sequence");
   n = PySequence_Size(arg); if (n < 0) goto end;
@@ -135,7 +135,7 @@ static PyObject *smallprimes(void)
   int i;
 
   for (i = 0; i < NPRIME; i++)
-    PyList_SetItem(v, i, PyInt_FromLong(primetab[i]));
+    PyList_SET_ITEM(v, i, PyInt_FromLong(primetab[i]));
   return (v);
 }
 
@@ -144,36 +144,38 @@ static PyObject *meth__ego(PyObject *me, PyObject *arg)
   char *argv0;
   if (!PyArg_ParseTuple(arg, "s:_ego", &argv0))
     return (0);
-  if (strcmp(QUIS, "<UNNAMED>") == 0)
+  if (STRCMP(QUIS, ==, "<UNNAMED>"))
     ego(argv0);
   RETURN_NONE;
 }
 
 static PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
-  METH (_ego,                  "_ego(ARGV0)")
+  METH (_ego,          "_ego(ARGV0)")
 #undef METHNAME
   { 0 }
 };
 
 static void init_random(void)
 {
-#if PY_MAJOR_VERSION >= 3 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6)
+#if PY_VERSION_HEX >= 0x02060000
   char *seed;
   uint32 r;
 
   if (!Py_HashRandomizationFlag) return;
   seed = getenv("PYTHONHASHSEED");
-  if (!seed || strcmp(seed, "random") == 0) r = GR_WORD(&rand_global);
+  if (!seed || STRCMP(seed, ==, "random")) r = GR_WORD(&rand_global);
   else r = strtoul(seed, 0, 0);
   if (!r) r = 0xe011f220; /* zero doesn't work well */
   unihash_setkey(&unihash_global, r);
 #endif
 }
 
-void init_base(void)
+EXPORT void init_base(void)
 {
   PyObject *mod;
+
+  modname = PyString_FromString("catacomb");
   addmethods(methods);
   INIT_MODULES;
   init_random();