pyke/pyke.h, key.c: Rename `INDEXERR' to `MAPERR'.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Oct 2019 18:17:41 +0000 (19:17 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:14 +0000 (12:44 +0100)
The name `INDEXERR' was pointlessly confusing, given the existing
`IXERR' which actually raises Python's `IndexError'.  It's important,
though, that `KEYERR' be reserved for Catacomb's `KeyError' exception,
which really is an error about (cryptographic) keys.  So `MAPERR' it is.

key.c
pyke/pyke.h

diff --git a/key.c b/key.c
index 634eb29..9745764 100644 (file)
--- a/key.c
+++ b/key.c
@@ -1098,7 +1098,7 @@ static PyObject *keydatastruct_pylookup(PyObject *me, PyObject *key)
   if ((tag = PyString_AsString(key)) == 0)
     goto end;
   if ((kd = key_structfind(KEYDATA_KD(me), tag)) == 0)
-    INDEXERR(key);
+    MAPERR(key);
   key_incref(kd);
   rc = keydata_pywrap(kd);
 end:
@@ -1120,7 +1120,7 @@ static int keydatastruct_pystore(PyObject *me,
     key_structset(KEYDATA_KD(me), tag, KEYDATA_KD(value));
   } else {
     if (!key_structfind(KEYDATA_KD(me), tag))
-      INDEXERR(key);
+      MAPERR(key);
     key_structset(KEYDATA_KD(me), tag, 0);
   }
   rc = 0;
@@ -1267,7 +1267,7 @@ static PyObject *keyattrs_pylookup(PyObject *me, PyObject *key)
   if ((attr = PyString_AsString(key)) == 0)
     goto end;
   if ((value = key_getattr(KEYATTRS_KF(me), KEYATTRS_K(me), attr)) == 0)
-    INDEXERR(key);
+    MAPERR(key);
   rc = PyString_FromString(value);
 end:
   return (rc);
@@ -1291,7 +1291,7 @@ static int keyattrs_pystore(PyObject *me,
       KEYERR(err);
   } else {
     if (!key_getattr(KEYATTRS_KF(me), KEYATTRS_K(me), attr))
-      INDEXERR(key);
+      MAPERR(key);
     if ((err = key_putattr(KEYATTRS_KF(me), KEYATTRS_K(me), attr, 0)) != 0)
       KEYERR(err);
   }
@@ -1925,7 +1925,7 @@ static PyObject *keyfile_pylookup(PyObject *me, PyObject *key)
   if (rc == Py_None) {
     Py_DECREF(rc);
     rc = 0;
-    INDEXERR(key);
+    MAPERR(key);
   }
 end:
   return (rc);
index 1f6232c..4e67464 100644 (file)
@@ -86,7 +86,7 @@ PRIVATE_SYMBOLS;
 #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
 #define SYSERR(str) EXCERR(PyExc_SystemError, str)
 #define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
-#define INDEXERR(idx) do {                                             \
+#define MAPERR(idx) do {                                               \
   PyErr_SetObject(PyExc_KeyError, idx);                                        \
   goto end;                                                            \
 } while (0)