*.c: Make all of the type-definition tables read-only.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Oct 2019 21:46:05 +0000 (22:46 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:14 +0000 (12:44 +0100)
The hard part is a new collection of macros which strip the `const'
qualifier from the actual table definitions, after checking that they
actually have the correct type.

And then there's the slog of actually changing all of the definitions
and using the new macros.

16 files changed:
algorithms.c
buffer.c
bytestring.c
ec.c
field.c
group.c
key.c
mp.c
passphrase.c
pgen.c
pubkey.c
pyke/mapping.c
pyke/pyke.c
pyke/pyke.h
rand.c
share.c

index d190a08..af98018 100644 (file)
@@ -213,7 +213,7 @@ static PyObject *ksget_max(PyObject *me, void *hunoz)
   return (PyInt_FromLong(x));
 }
 
-static PyMemberDef keysz_pymembers[] = {
+static const PyMemberDef keysz_pymembers[] = {
 #define MEMBERSTRUCT keysz_pyobj
 #define default dfl /* ugh! */
   MEMBER(default, T_INT,  READONLY, "KSZ.default -> default key size")
@@ -222,7 +222,7 @@ static PyMemberDef keysz_pymembers[] = {
   { 0 }
 };
 
-static PyGetSetDef keyszany_pygetset[] = {
+static const PyGetSetDef keyszany_pygetset[] = {
 #define GETSETNAME(op, name) ka##op##_##name
   GET  (min,           "KSZ.min -> smallest allowed key size")
   GET  (max,           "KSZ.max -> largest allowed key size")
@@ -230,7 +230,7 @@ static PyGetSetDef keyszany_pygetset[] = {
   { 0 }
 };
 
-static PyMemberDef keyszrange_pymembers[] = {
+static const PyMemberDef keyszrange_pymembers[] = {
 #define MEMBERSTRUCT keyszrange_pyobj
   MEMBER(min,  T_INT,    READONLY, "KSZ.min -> smallest allowed key size")
   MEMBER(max,  T_INT,    READONLY, "KSZ.max -> largest allowed key size")
@@ -240,7 +240,7 @@ static PyMemberDef keyszrange_pymembers[] = {
   { 0 }
 };
 
-static PyGetSetDef keyszset_pygetset[] = {
+static const PyGetSetDef keyszset_pygetset[] = {
 #define GETSETNAME(op, name) ks##op##_##name
   GET  (min,           "KSZ.min -> smallest allowed key size")
   GET  (max,           "KSZ.max -> largest allowed key size")
@@ -248,7 +248,7 @@ static PyGetSetDef keyszset_pygetset[] = {
   { 0 }
 };
 
-static PyMemberDef keyszset_pymembers[] = {
+static const PyMemberDef keyszset_pymembers[] = {
 #define MEMBERSTRUCT keyszset_pyobj
   MEMBER(set,  T_OBJECT, READONLY, "KSZ.set -> allowed key sizes")
 #undef MEMBERSTRUCT
@@ -289,7 +289,7 @@ static PyTypeObject keysz_pytype_skel = {
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
-  keysz_pymembers,                     /* @tp_members@ */
+  PYMEMBERS(keysz),                    /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -339,7 +339,7 @@ static PyTypeObject keyszany_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keyszany_pygetset,                   /* @tp_getset@ */
+  PYGETSET(keyszany),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -388,7 +388,7 @@ static PyTypeObject keyszrange_pytype_skel = {
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
-  keyszrange_pymembers,                        /* @tp_members@ */
+  PYMEMBERS(keyszrange),               /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -437,8 +437,8 @@ static PyTypeObject keyszset_pytype_skel = {
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
-  keyszset_pymembers,                  /* @tp_members@ */
-  keyszset_pygetset,                   /* @tp_getset@ */
+  PYMEMBERS(keyszset),                 /* @tp_members@ */
+  PYGETSET(keyszset),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -627,7 +627,7 @@ end:
   return (0);
 }
 
-static PyGetSetDef gccipher_pygetset[] = {
+static const PyGetSetDef gccipher_pygetset[] = {
 #define GETSETNAME(op, name) gcc##op##_##name
   GET  (keysz,         "CC.keysz -> acceptable key sizes")
   GET  (blksz,         "CC.blksz -> block size, or zero")
@@ -636,7 +636,7 @@ static PyGetSetDef gccipher_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef gcipher_pymethods[] = {
+static const PyMethodDef gcipher_pymethods[] = {
 #define METHNAME(name) gcmeth_##name
   METH (encrypt,       "C.encrypt(PT) -> CT")
   METH (enczero,       "C.enczero(N) -> CT")
@@ -683,7 +683,7 @@ static PyTypeObject gccipher_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gccipher_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gccipher),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -729,7 +729,7 @@ static PyTypeObject gcipher_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gcipher_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(gcipher),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -938,7 +938,7 @@ static PyObject *gcaeget_ohd(PyObject *me, void *hunoz)
 static PyObject *gcaeget_flags(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GCAEAD_AEC(me)->f)); }
 
-static PyGetSetDef gcaead_pygetset[] = {
+static const PyGetSetDef gcaead_pygetset[] = {
 #define GETSETNAME(op, name) gcae##op##_##name
   GET  (keysz,         "AEC.keysz -> acceptable key sizes")
   GET  (noncesz,       "AEC.noncesz -> acceptable nonce sizes")
@@ -1042,7 +1042,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeadkey_pymethods[] = {
+static const PyMethodDef gaeadkey_pymethods[] = {
 #define METHNAME(name) gaekmeth_##name
   METH (aad,           "KEY.aad() -> AAD")
   KWMETH(enc,          "KEY.enc(NONCE, [hsz], [msz], [tsz]) -> ENC")
@@ -1100,7 +1100,7 @@ static PyObject *gaeaget_hsz(PyObject *me, void *hunoz)
 static PyObject *gaeaget_hlen(PyObject *me, void *hunoz)
   { return (gaea_check(me) ? 0 : getulong(GAEADAAD_HLEN(me))); }
 
-static PyGetSetDef gaeadaad_pygetset[] = {
+static const PyGetSetDef gaeadaad_pygetset[] = {
 #define GETSETNAME(op, name) gaea##op##_##name
   GET  (hsz,           "AAD.hsz -> precommitted header length or `None'")
   GET  (hlen,          "AAD.hlen -> header length so far")
@@ -1181,7 +1181,7 @@ static PyObject *gaeameth_hashstrz(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyMethodDef gaeadaad_pymethods[] = {
+static const PyMethodDef gaeadaad_pymethods[] = {
 #define METHNAME(name) gaeameth_##name
   METH (copy,          "AAD.copy() -> AAD'")
   METH (hash,          "AAD.hash(H)")
@@ -1237,7 +1237,7 @@ static PyObject *gaeeget_tsz(PyObject *me, void *hunoz)
 static PyObject *gaeeget_mlen(PyObject *me, void *hunoz)
   { return getulong(GAEADENC_MLEN(me)); }
 
-static PyGetSetDef gaeadenc_pygetset[] = {
+static const PyGetSetDef gaeadenc_pygetset[] = {
 #define GETSETNAME(op, name) gaee##op##_##name
   GET  (hsz,           "ENC.hsz -> precommitted header length or `None'")
   GET  (msz,           "ENC.msz -> precommitted message length or `None'")
@@ -1362,7 +1362,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeadenc_pymethods[] = {
+static const PyMethodDef gaeadenc_pymethods[] = {
 #define METHNAME(name) gaeemeth_##name
   METH (aad,           "ENC.aad() -> AAD")
   KWMETH(reinit,       "ENC.reinit(NONCE, [hsz], [msz], [tsz])")
@@ -1412,7 +1412,7 @@ static PyObject *gaedget_tsz(PyObject *me, void *hunoz)
 static PyObject *gaedget_clen(PyObject *me, void *hunoz)
   { return getulong(GAEADDEC_CLEN(me)); }
 
-static PyGetSetDef gaeaddec_pygetset[] = {
+static const PyGetSetDef gaeaddec_pygetset[] = {
 #define GETSETNAME(op, name) gaed##op##_##name
   GET  (hsz,           "DEC.hsz -> precommitted header length or `None'")
   GET  (csz,          "DEC.csz -> precommitted ciphertext length or `None'")
@@ -1525,7 +1525,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeaddec_pymethods[] = {
+static const PyMethodDef gaeaddec_pymethods[] = {
 #define METHNAME(name) gaedmeth_##name
   METH (aad,           "DEC.aad() -> AAD")
   KWMETH(reinit,       "DEC.reinit(NONCE, [hsz], [csz], [tsz])")
@@ -1570,7 +1570,7 @@ static PyTypeObject gcaead_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcaead_pygetset,                     /* @tp_getset@ */
+  PYGETSET(gcaead),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1616,7 +1616,7 @@ static PyTypeObject gaeadkey_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadkey_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadkey),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -1712,9 +1712,9 @@ static PyTypeObject gaeadaad_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadaad_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadaad),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeadaad_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeadaad),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1808,9 +1808,9 @@ static PyTypeObject gaeadenc_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadenc_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadenc),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeadenc_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeadenc),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1904,9 +1904,9 @@ static PyTypeObject gaeaddec_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeaddec_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeaddec),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeaddec_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeaddec),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2048,7 +2048,7 @@ static PyObject *ghmeth_done(PyObject *me, PyObject *arg)
   return (rc);
 }
 
-static PyGetSetDef gchash_pygetset[] = {
+static const PyGetSetDef gchash_pygetset[] = {
 #define GETSETNAME(op, name) gch##op##_##name
   GET  (bufsz,         "CH.bufsz -> hash buffer size, or zero")
   GET  (hashsz,        "CH.hashsz -> hash output size")
@@ -2057,7 +2057,7 @@ static PyGetSetDef gchash_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ghash_pymethods[] = {
+static const PyMethodDef ghash_pymethods[] = {
 #define METHNAME(name) ghmeth_##name
   METH (copy,          "H.copy() -> HH")
   METH (hash,          "H.hash(M)")
@@ -2108,7 +2108,7 @@ static PyTypeObject gchash_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gchash_pygetset,                     /* @tp_getset@ */
+  PYGETSET(gchash),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2154,7 +2154,7 @@ static PyTypeObject ghash_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ghash_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(ghash),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -2278,7 +2278,7 @@ static PyObject *gcmget_keysz(PyObject *me, void *hunoz)
 static PyObject *gcmget_tagsz(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GCMAC_CM(me)->hashsz)); }
 
-static PyGetSetDef gcmac_pygetset[] = {
+static const PyGetSetDef gcmac_pygetset[] = {
 #define GETSETNAME(op, name) gcm##op##_##name
   GET  (keysz,         "CM.keysz -> acceptable key sizes")
   GET  (tagsz,         "CM.tagsz -> MAC output size")
@@ -2322,7 +2322,7 @@ static PyTypeObject gcmac_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcmac_pygetset,                      /* @tp_getset@ */
+  PYGETSET(gcmac),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2614,7 +2614,7 @@ end:
   return (0);
 }
 
-static PyGetSetDef poly1305cls_pygetset[] = {
+static const PyGetSetDef poly1305cls_pygetset[] = {
 #define GETSETNAME(op, name) poly1305cls##op##_##name
   GET  (keysz,         "PC.keysz -> acceptable key sizes")
   GET  (masksz,        "PC.masksz -> mask size")
@@ -2624,7 +2624,7 @@ static PyGetSetDef poly1305cls_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef poly1305hash_pymethods[] = {
+static const PyMethodDef poly1305hash_pymethods[] = {
 #define METHNAME(name) polymeth_##name
   METH (copy,          "P.copy() -> PP")
   METH (hash,          "P.hash(M)")
@@ -2678,7 +2678,7 @@ static PyTypeObject poly1305cls_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  poly1305cls_pygetset,                        /* @tp_getset@ */
+  PYGETSET(poly1305cls),               /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2772,7 +2772,7 @@ static PyTypeObject poly1305hash_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  poly1305hash_pymethods,              /* @tp_methods@ */
+  PYMETHODS(poly1305hash),             /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -2925,14 +2925,14 @@ end:
   return (rc);
 }
 
-static PyGetSetDef kxvik_pygetset[] = {
+static const PyGetSetDef kxvik_pygetset[] = {
 #define GETSETNAME(op, name) kxvik##op##_##name
   GETSET(nround,       "KECCAK.nround -> number of rounds")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef kxvik_pymethods[] = {
+static const PyMethodDef kxvik_pymethods[] = {
 #define METHNAME(func) kxvikmeth_##func
   METH (copy,          "KECCAK.copy() -> KECCAK'")
   METH (mix,           "KECCAK.mix(DATA)")
@@ -2975,9 +2975,9 @@ static PyTypeObject kxvik_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  kxvik_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(kxvik),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  kxvik_pygetset,                      /* @tp_getset@ */
+  PYGETSET(kxvik),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3161,7 +3161,7 @@ static PyObject *shakeget_state(PyObject *me, void *hunoz)
                              st == 1 ? "squeeze" : "dead"));
 }
 
-static PyGetSetDef shake_pygetset[] = {
+static const PyGetSetDef shake_pygetset[] = {
 #define GETSETNAME(op, name) shake##op##_##name
   GET  (rate,          "S.rate -> rate, in bytes")
   GET  (buffered,      "S.buffered -> amount currently buffered")
@@ -3170,7 +3170,7 @@ static PyGetSetDef shake_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef shake_pymethods[] = {
+static const PyMethodDef shake_pymethods[] = {
 #define METHNAME(func) shakemeth_##func
   METH (copy,          "S.copy() -> SS")
   METH (hash,          "S.hash(M)")
@@ -3222,9 +3222,9 @@ static PyTypeObject shake_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  shake_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(shake),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  shake_pygetset,                      /* @tp_getset@ */
+  PYGETSET(shake),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3465,7 +3465,7 @@ end:
   return (rc);
 }
 
-static PyGetSetDef gcprp_pygetset[] = {
+static const PyGetSetDef gcprp_pygetset[] = {
 #define GETSETNAME(op, name) gcp##op##_##name
   GET  (keysz,         "CP.keysz -> acceptable key sizes")
   GET  (blksz,         "CP.blksz -> block size")
@@ -3474,7 +3474,7 @@ static PyGetSetDef gcprp_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef gprp_pymethods[] = {
+static const PyMethodDef gprp_pymethods[] = {
 #define METHNAME(name) gpmeth_##name
   METH (encrypt,       "P.encrypt(PT) -> CT")
   METH (decrypt,       "P.decrypt(CT) -> PT")
@@ -3517,7 +3517,7 @@ static PyTypeObject gcprp_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcprp_pygetset,                      /* @tp_getset@ */
+  PYGETSET(gcprp),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3563,7 +3563,7 @@ static PyTypeObject gprp_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gprp_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(gprp),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -3580,7 +3580,7 @@ static PyTypeObject gprp_pytype_skel = {
 
 /*----- Main code ---------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH (_KeySZ_fromdl, "fromdl(N) -> M: "
                    "convert integer discrete log field size to work factor")
index 43ed43d..49ed9d2 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -245,7 +245,7 @@ end:
   return (-1);
 }
 
-static PyGetSetDef rbuf_pygetset[] = {
+static const PyGetSetDef rbuf_pygetset[] = {
 #define GETSETNAME(op, name) rb##op##_##name
   GET  (size,          "RBUF.size -> SIZE")
   GET  (left,          "RBUF.left -> REMAINDER")
@@ -255,7 +255,7 @@ static PyGetSetDef rbuf_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef rbuf_pymethods[] = {
+static const PyMethodDef rbuf_pymethods[] = {
 #define METHNAME(func) rbmeth_##func
   METH (skip,          "RBUF.skip(N)")
   METH (get,           "RBUF.get(N) -> BYTES")
@@ -278,7 +278,7 @@ static PyMethodDef rbuf_pymethods[] = {
   { 0 }
 };
 
-static PyBufferProcs rbuf_pybuffer = {
+static const PyBufferProcs rbuf_pybuffer = {
   rbuf_pyreadbuf,                      /* @bf_getreadbuffer@ */
   0,                                   /* @bf_getwritebuffer@ */
   rbuf_pysegcount,                     /* @bf_getsegcount@ */
@@ -305,7 +305,7 @@ static PyTypeObject rbuf_pytype_skel = {
   0,                                   /* @tp_str@ */
   0,                                   /* @tp_getattro@ */
   0,                                   /* @tp_setattro@ */
-  &rbuf_pybuffer,                      /* @tp_as_buffer@ */
+  PYBUFFER(rbuf),                      /* @tp_as_buffer@ */
   Py_TPFLAGS_DEFAULT |                 /* @tp_flags@ */
     Py_TPFLAGS_BASETYPE,
 
@@ -318,9 +318,9 @@ static PyTypeObject rbuf_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  rbuf_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(rbuf),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  rbuf_pygetset,                       /* @tp_getset@ */
+  PYGETSET(rbuf),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -490,7 +490,7 @@ static PyObject *wbget_size(PyObject *me, void *hunoz)
 static PyObject *wbget_contents(PyObject *me, void *hunoz)
   { return (bytestring_pywrap(BBASE(BUF_B(me)), BLEN(BUF_B(me)))); }
 
-static PyGetSetDef wbuf_pygetset[] = {
+static const PyGetSetDef wbuf_pygetset[] = {
 #define GETSETNAME(op, name) wb##op##_##name
   GET  (size,          "WBUF.size -> SIZE")
   GET  (contents,      "WBUF.contents -> STR")
@@ -498,7 +498,7 @@ static PyGetSetDef wbuf_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef wbuf_pymethods[] = {
+static const PyMethodDef wbuf_pymethods[] = {
 #define METHNAME(func) wbmeth_##func
   METH (zero,          "WBUF.zero(N)")
   METH (put,           "WBUF.put(BYTES)")
@@ -518,7 +518,7 @@ static PyMethodDef wbuf_pymethods[] = {
   { 0 }
 };
 
-static PyBufferProcs wbuf_pybuffer = {
+static const PyBufferProcs wbuf_pybuffer = {
   wbuf_pyreadbuf,                      /* @bf_getreadbuffer@ */
   0,                                   /* @bf_getwritebuffer@ */
   wbuf_pysegcount,                     /* @bf_getsegcount@ */
@@ -545,7 +545,7 @@ static PyTypeObject wbuf_pytype_skel = {
   0,                                   /* @tp_str@ */
   0,                                   /* @tp_getattro@ */
   0,                                   /* @tp_setattro@ */
-  &wbuf_pybuffer,                      /* @tp_as_buffer@ */
+  PYBUFFER(wbuf),                      /* @tp_as_buffer@ */
   Py_TPFLAGS_DEFAULT |                 /* @tp_flags@ */
     Py_TPFLAGS_BASETYPE,
 
@@ -558,9 +558,9 @@ static PyTypeObject wbuf_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  wbuf_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(wbuf),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  wbuf_pygetset,                       /* @tp_getset@ */
+  PYGETSET(wbuf),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
index eef8ed1..2468ea2 100644 (file)
@@ -265,7 +265,7 @@ BINOP(xor, ^)
   }
 UNOP(not, ~)
 
-static PyNumberMethods bytestring_pynumber = {
+static const PyNumberMethods bytestring_pynumber = {
   0,                                   /* @nb_add@ */
   0,                                   /* @nb_subtract@ */
   0,                                   /* @nb_multiply@ */
@@ -291,7 +291,7 @@ static PyNumberMethods bytestring_pynumber = {
   0,                                   /* @nb_hex@ */
 };
 
-static PySequenceMethods bytestring_pysequence = {
+static const PySequenceMethods bytestring_pysequence = {
   0,                                   /* @sq_length@ */
   bytestring_pyconcat,                 /* @sq_concat@ */
   bytestring_pyrepeat,                 /* @sq_repeat@ */
@@ -304,7 +304,7 @@ static PySequenceMethods bytestring_pysequence = {
   0,                                   /* @sq_inplace_repeat@ */
 };
 
-static PyMappingMethods bytestring_pymapping = {
+static const PyMappingMethods bytestring_pymapping = {
   0,                                   /* @mp_length@ */
   bytestring_pysubscript,              /* @mp_subscript@ */
   0,                                   /* @mp_ass_subscript@ */
@@ -322,9 +322,9 @@ static PyTypeObject bytestring_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &bytestring_pynumber,                        /* @tp_as_number@ */
-  &bytestring_pysequence,              /* @tp_as_sequence@ */
-  &bytestring_pymapping,               /* @tp_as_mapping@ */
+  PYNUMBER(bytestring),                        /* @tp_as_number@ */
+  PYSEQUENCE(bytestring),              /* @tp_as_sequence@ */
+  PYMAPPING(bytestring),               /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
   0,                                   /* @tp_call@ */
   0,                                   /* @tp_str@ */
@@ -361,7 +361,7 @@ static PyTypeObject bytestring_pytype_skel = {
 
 /*----- Initialization ----------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH (ctstreq,       "ctstreq(S, T) -> BOOL")
   METH (_ByteString_zero, "zero(N) -> 0000...00")
diff --git a/ec.c b/ec.c
index edf6ed6..d55cd3f 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -555,7 +555,7 @@ end:
   return (0);
 }
 
-static PyGetSetDef ecptnc_pygetset[] = {
+static const PyGetSetDef ecptnc_pygetset[] = {
 #define GETSETNAME(op, name) epnc##op##_##name
   GET  (ix,            "P.ix -> integer x coordinate of P")
   GET  (iy,            "P.iy -> integer y coordinate of P")
@@ -564,14 +564,14 @@ static PyGetSetDef ecptnc_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecptnc_pymethods[] = {
+static const PyMethodDef ecptnc_pymethods[] = {
 #define METHNAME(func) epmeth_##func
   METH (tobuf,         "X.tobuf() -> BIN")
 #undef METHNAME
   { 0 }
 };
 
-static PyNumberMethods ecpt_pynumber = {
+static const PyNumberMethods ecpt_pynumber = {
   0,                                   /* @nb_add@ */
   0,                                   /* @nb_subtract@ */
   0,                                   /* @nb_multiply@ */
@@ -626,7 +626,7 @@ static PyTypeObject ecpt_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &ecpt_pynumber,                      /* @tp_as_number@ */
+  PYNUMBER(ecpt),                      /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   ecpt_pyhash,                         /* @tp_hash@ */
@@ -650,9 +650,9 @@ static PyTypeObject ecpt_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecptnc_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(ecptnc),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecptnc_pygetset,                     /* @tp_getset@ */
+  PYGETSET(ecptnc),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -665,7 +665,7 @@ static PyTypeObject ecpt_pytype_skel = {
   0                                    /* @tp_is_gc@ */
 };
 
-static PyGetSetDef ecpt_pygetset[] = {
+static const PyGetSetDef ecpt_pygetset[] = {
 #define GETSETNAME(op, name) ep##op##_##name
   GET  (curve,         "P.curve -> elliptic curve containing P")
   GET  (point,         "P.point -> standalone curve point")
@@ -678,7 +678,7 @@ static PyGetSetDef ecpt_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecpt_pymethods[] = {
+static const PyMethodDef ecpt_pymethods[] = {
 #define METHNAME(func) epmeth_##func
   METH (toraw,         "X.toraw() -> BIN")
   KWMETH(ec2osp,       "X.ec2osp([flags = EC_EXPLY]) -> BIN")
@@ -688,7 +688,7 @@ static PyMethodDef ecpt_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods ecptcurve_pynumber = {
+static const PyNumberMethods ecptcurve_pynumber = {
   ecpt_pyadd,                          /* @nb_add@ */
   ecpt_pysub,                          /* @nb_subtract@ */
   ecpt_pymul,                          /* @nb_multiply@ */
@@ -743,7 +743,7 @@ static PyTypeObject ecptcurve_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &ecptcurve_pynumber,                 /* @tp_as_number@ */
+  PYNUMBER(ecptcurve),                 /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
@@ -765,9 +765,9 @@ static PyTypeObject ecptcurve_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecpt_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(ecpt),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecpt_pygetset,                       /* @tp_getset@ */
+  PYGETSET(ecpt),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1050,7 +1050,7 @@ static PyObject *ecget_field(PyObject *me, void *hunoz)
 static PyObject *ecget_inf(PyObject *me, void *hunoz)
   { ec inf = EC_INIT; return (ecpt_pywrap(me, &inf)); }
 
-static PyGetSetDef eccurve_pygetset[] = {
+static const PyGetSetDef eccurve_pygetset[] = {
 #define GETSETNAME(op, name) ec##op##_##name
   GET  (name,          "E.name -> name of this kind of curve")
   GET  (a,             "E.a -> first parameter of curve")
@@ -1061,7 +1061,7 @@ static PyGetSetDef eccurve_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef eccurve_pymethods[] = {
+static const PyMethodDef eccurve_pymethods[] = {
 #define METHNAME(name) ecmeth_##name
   METH (mmul,     "E.mmul([(P0, N0), (P1, N1), ...]) = N0 P0 + N1 P1 + ...")
   METH (find,          "E.find(X) -> P")
@@ -1103,9 +1103,9 @@ static PyTypeObject eccurve_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  eccurve_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(eccurve),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  eccurve_pygetset,                    /* @tp_getset@ */
+  PYGETSET(eccurve),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1478,7 +1478,7 @@ static PyObject *eiget_r(PyObject *me, void *hunoz)
 static PyObject *eiget_h(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(ECINFO_EI(me)->h))); }
 
-static PyGetSetDef ecinfo_pygetset[] = {
+static const PyGetSetDef ecinfo_pygetset[] = {
 #define GETSETNAME(op, name) ei##op##_##name
   GET  (curve,         "I.curve -> the elliptic curve")
   GET  (G,             "I.G -> generator point for the group")
@@ -1488,7 +1488,7 @@ static PyGetSetDef ecinfo_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecinfo_pymethods[] = {
+static const PyMethodDef ecinfo_pymethods[] = {
 #define METHNAME(name) eimeth_##name
   KWMETH(check,                "I.check([rng = rand]) -> None")
 #undef METHNAME
@@ -1528,9 +1528,9 @@ static PyTypeObject ecinfo_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecinfo_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(ecinfo),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecinfo_pygetset,                     /* @tp_getset@ */
+  PYGETSET(ecinfo),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1545,7 +1545,7 @@ static PyTypeObject ecinfo_pytype_skel = {
 
 /*----- Setup -------------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH (_ECPt_frombuf, "frombuf(E, STR) -> (P, REST)")
   METH (_ECPtCurve_fromraw, "fromraw(E, STR) -> (P, REST)")
diff --git a/field.c b/field.c
index e33fdfd..8091843 100644 (file)
--- a/field.c
+++ b/field.c
@@ -324,7 +324,7 @@ static PyObject *feget__value(PyObject *me, void *hunoz)
     return (mp_pywrap(x));
 }
 
-static PyGetSetDef fe_pygetset[] = {
+static const PyGetSetDef fe_pygetset[] = {
 #define GETSETNAME(op, name) fe##op##_##name
   GET  (field,         "X.field -> field containing X")
   GET  (value,         "X.value -> `natural' MP/GF representation of X")
@@ -333,7 +333,7 @@ static PyGetSetDef fe_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef fe_pymethods[] = {
+static const PyMethodDef fe_pymethods[] = {
 #define METHNAME(func) femeth_##func
   METH (inv,           "X.inv() -> X^{-1}")
   METH (sqr,           "X.sqr() -> X^2")
@@ -347,7 +347,7 @@ static PyMethodDef fe_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods fe_pynumber = {
+static const PyNumberMethods fe_pynumber = {
   fe_pyadd,                            /* @nb_add@ */
   fe_pysub,                            /* @nb_subtract@ */
   fe_pymul,                            /* @nb_multiply@ */
@@ -402,7 +402,7 @@ static PyTypeObject fe_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &fe_pynumber,                                /* @tp_as_number@ */
+  PYNUMBER(fe),                                /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   fe_pyhash,                           /* @tp_hash@ */
@@ -424,9 +424,9 @@ static PyTypeObject fe_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  fe_pymethods,                                /* @tp_methods@ */
+  PYMETHODS(fe),                       /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  fe_pygetset,                         /* @tp_getset@ */
+  PYGETSET(fe),                                /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -499,7 +499,7 @@ static PyObject *fget_name(PyObject *me, void *hunoz)
 static PyObject *fget_type(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(F_TYPE(FIELD_F(me)))); }
 
-static PyGetSetDef field_pygetset[] = {
+static const PyGetSetDef field_pygetset[] = {
 #define GETSETNAME(op, name) f##op##_##name
   GET  (zero,          "F.zero -> field additive identity")
   GET  (one,           "F.one -> field multiplicative identity")
@@ -512,7 +512,7 @@ static PyGetSetDef field_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef field_pymethods[] = {
+static const PyMethodDef field_pymethods[] = {
 #define METHNAME(name) fmeth_##name
   METH (_adopt,        "F._adopt(X) -> FE")
   KWMETH(rand,         "F.rand([rng = rand]) -> FE, uniformly distributed")
@@ -553,9 +553,9 @@ static PyTypeObject field_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  field_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(field),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  field_pygetset,                      /* @tp_getset@ */
+  PYGETSET(field),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -592,7 +592,7 @@ end:
 static PyObject *pfget_p(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(FIELD_F(me)->m))); }
 
-static PyGetSetDef primefield_pygetset[] = {
+static const PyGetSetDef primefield_pygetset[] = {
 #define GETSETNAME(op, name) pf##op##_##name
   GET  (p,             "F.p -> prime field characteristic")
 #undef GETSETNAME
@@ -633,7 +633,7 @@ static PyTypeObject primefield_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  primefield_pygetset,                 /* @tp_getset@ */
+  PYGETSET(primefield),                        /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -721,7 +721,7 @@ static PyObject *bfget_m(PyObject *me, void *hunoz)
 static PyObject *bfget_p(PyObject *me, void *hunoz)
   { return (gf_pywrap(MP_COPY(FIELD_F(me)->m))); }
 
-static PyGetSetDef binfield_pygetset[] = {
+static const PyGetSetDef binfield_pygetset[] = {
 #define GETSETNAME(op, name) bf##op##_##name
   GET  (m,             "F.m -> field polynomial degree")
   GET  (p,             "F.p -> field polynomial")
@@ -764,7 +764,7 @@ static PyTypeObject binfield_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  binfield_pygetset,                   /* @tp_getset@ */
+  PYGETSET(binfield),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -867,7 +867,7 @@ static PyObject *bnfget_beta(PyObject *me, void *hunoz)
   return (gf_pywrap(MP_COPY(fc->ntop.r[fc->ntop.n - 1])));
 }
 
-static PyGetSetDef binnormfield_pygetset[] = {
+static const PyGetSetDef binnormfield_pygetset[] = {
 #define GETSETNAME(op, name) bnf##op##_##name
   GET  (beta,          "F.beta -> conversion factor")
 #undef GETSETNAME
@@ -909,7 +909,7 @@ static PyTypeObject binnormfield_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  binnormfield_pygetset,               /* @tp_getset@ */
+  PYGETSET(binnormfield),              /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -942,7 +942,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH (_Field_parse,  "parse(STR) -> F, REST")
 #undef METHNAME
diff --git a/group.c b/group.c
index 3a4b05b..bdf75b1 100644 (file)
--- a/group.c
+++ b/group.c
@@ -295,14 +295,14 @@ static PyObject *meth__DHInfo_parse(PyObject *me, PyObject *arg)
 static PyObject *meth__BinDHInfo_parse(PyObject *me, PyObject *arg)
   { return (meth__parse(me, arg, bindhinfo_pytype, dhbin_parse)); }
 
-static PyGetSetDef fginfo_pygetset[] = {
+static const PyGetSetDef fginfo_pygetset[] = {
 #define GETSETNAME(op, name) fi##op##_##name
   GET  (r,             "I.r -> group order")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyGetSetDef dhinfo_pygetset[] = {
+static const PyGetSetDef dhinfo_pygetset[] = {
 #define GETSETNAME(op, name) di##op##_##name
   GET  (p,             "I.p -> prime")
   GET  (g,             "I.g -> generator")
@@ -310,7 +310,7 @@ static PyGetSetDef dhinfo_pygetset[] = {
   { 0 }
 };
 
-static PyGetSetDef bindhinfo_pygetset[] = {
+static const PyGetSetDef bindhinfo_pygetset[] = {
 #define GETSETNAME(op, name) bi##op##_##name
   GET  (p,             "I.p -> irreducible polynomial")
   GET  (m,             "I.m -> degree of polynomial")
@@ -354,7 +354,7 @@ static PyTypeObject fginfo_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  fginfo_pygetset,                     /* @tp_getset@ */
+  PYGETSET(fginfo),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -402,7 +402,7 @@ static PyTypeObject dhinfo_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  dhinfo_pygetset,                     /* @tp_getset@ */
+  PYGETSET(dhinfo),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -450,7 +450,7 @@ static PyTypeObject bindhinfo_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  bindhinfo_pygetset,                  /* @tp_getset@ */
+  PYGETSET(bindhinfo),                 /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -969,14 +969,14 @@ static PyObject *gget_r(PyObject *me, void *hunoz)
 static PyObject *gget_h(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(GROUP_G(me)->h))); }
 
-static PyGetSetDef ge_pygetset[] = {
+static const PyGetSetDef ge_pygetset[] = {
 #define GETSETNAME(op, name) ge##op##_##name
   GET  (group,         "X.group -> group containing X")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef ge_pymethods[] = {
+static const PyMethodDef ge_pymethods[] = {
 #define METHNAME(name) gemeth_##name
   METH (inv,           "X.inv() -> inverse element of X")
   METH (sqr,           "X.sqr() -> X^2 = X * X")
@@ -990,7 +990,7 @@ static PyMethodDef ge_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods ge_pynumber = {
+static const PyNumberMethods ge_pynumber = {
   0,                                   /* @nb_add@ */
   0,                                   /* @nb_subtract@ */
   ge_pymul,                            /* @nb_multiply@ */
@@ -1045,7 +1045,7 @@ static PyTypeObject ge_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &ge_pynumber,                                /* @tp_as_number@ */
+  PYNUMBER(ge),                                /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   ge_pyhash,                           /* @tp_hash@ */
@@ -1067,9 +1067,9 @@ static PyTypeObject ge_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ge_pymethods,                                /* @tp_methods@ */
+  PYMETHODS(ge),                       /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ge_pygetset,                         /* @tp_getset@ */
+  PYGETSET(ge),                                /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1082,7 +1082,7 @@ static PyTypeObject ge_pytype_skel = {
   0                                    /* @tp_is_gc@ */
 };
 
-static PyGetSetDef group_pygetset[] = {
+static const PyGetSetDef group_pygetset[] = {
 #define GETSETNAME(op, name) g##op##_##name
   GET  (noctets,       "G.noctets -> size in octets of element")
   GET  (nbits,         "G.nbits -> size in bits of element")
@@ -1094,7 +1094,7 @@ static PyGetSetDef group_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef group_pymethods[] = {
+static const PyMethodDef group_pymethods[] = {
 #define METHNAME(name) gmeth_##name
   METH (mexp,        "G.mexp([(X0, N0), (X1, N1), ...]) -> X0^N0 X1^N1 ...")
   KWMETH(checkgroup,   "G.checkgroup([rng = rand]): check group is good")
@@ -1135,9 +1135,9 @@ static PyTypeObject group_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  group_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(group),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  group_pygetset,                      /* @tp_getset@ */
+  PYGETSET(group),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1160,7 +1160,7 @@ static PyObject *pgget_info(PyObject *me, void *hunoz)
   return (fginfo_pywrap(&dp, dhinfo_pytype));
 }
 
-static PyGetSetDef primegroup_pygetset[] = {
+static const PyGetSetDef primegroup_pygetset[] = {
 #define GETSETNAME(op, name) pg##op##_##name
   GET  (info,          "G.info -> information about the group")
 #undef GETSETNAME
@@ -1214,7 +1214,7 @@ static PyTypeObject primegroup_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  primegroup_pygetset,                 /* @tp_getset@ */
+  PYGETSET(primegroup),                        /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1237,7 +1237,7 @@ static PyObject *bgget_info(PyObject *me, void *hunoz)
   return (fginfo_pywrap(&dp, bindhinfo_pytype));
 }
 
-static PyGetSetDef bingroup_pygetset[] = {
+static const PyGetSetDef bingroup_pygetset[] = {
 #define GETSETNAME(op, name) bg##op##_##name
   GET  (info,          "G.info -> information about the group")
 #undef GETSETNAME
@@ -1291,7 +1291,7 @@ static PyTypeObject bingroup_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  bingroup_pygetset,                   /* @tp_getset@ */
+  PYGETSET(bingroup),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1313,7 +1313,7 @@ static PyObject *egget_info(PyObject *me, void *hunoz)
   return (ecinfo_pywrap(&ei));
 }
 
-static PyGetSetDef ecgroup_pygetset[] = {
+static const PyGetSetDef ecgroup_pygetset[] = {
 #define GETSETNAME(op, name) eg##op##_##name
   GET  (info,          "G.info -> information about the group")
 #undef GETSETNAME
@@ -1369,7 +1369,7 @@ static PyTypeObject ecgroup_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecgroup_pygetset,                    /* @tp_getset@ */
+  PYGETSET(ecgroup),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1384,7 +1384,7 @@ static PyTypeObject ecgroup_pytype_skel = {
 
 /*----- Global stuff ------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   METH (_GE_frombuf,   "frombuf(BUF) -> X, REST")
   METH (_GE_fromraw,   "fromraw(BUF) -> X, REST")
diff --git a/key.c b/key.c
index 9745764..b6a8c6a 100644 (file)
--- a/key.c
+++ b/key.c
@@ -96,7 +96,7 @@ done:
   return (rc);
 }
 
-static PyMethodDef keyexc_pymethods[] = {
+static const PyMethodDef keyexc_pymethods[] = {
 #define METHNAME(func) kxmeth_##func
   METH (__init__,      "KeyError(CODE)")
   METH (__str__,       "E.__str__() -> STRING")
@@ -463,7 +463,7 @@ end:
 static PyObject *kdget_flags(PyObject *me, void *hunoz)
   { return (getulong(KEYDATA_KD(me)->e)); }
 
-static PyMethodDef keydata_pymethods[] = {
+static const PyMethodDef keydata_pymethods[] = {
 #define METHNAME(func) kdmeth_##func
   METH (matchp,        "KD.matchp(FILTER) -> BOOL")
   METH (split,         "KD.split()")
@@ -476,7 +476,7 @@ static PyMethodDef keydata_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef keydata_pygetset[] = {
+static const PyGetSetDef keydata_pygetset[] = {
 #define GETSETNAME(op, name) kd##op##_##name
   GET  (flags,         "KD.flags -> FLAGS")
 #undef GETSETNAME
@@ -516,9 +516,9 @@ static PyTypeObject keydata_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  keydata_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(keydata),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydata_pygetset,                    /* @tp_getset@ */
+  PYGETSET(keydata),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -553,7 +553,7 @@ static PyObject *kdbget_bin(PyObject *me, void *hunoz)
   { return (bytestring_pywrap(KEYDATA_KD(me)->u.k.k,
                              KEYDATA_KD(me)->u.k.sz)); }
 
-static PyGetSetDef keydatabin_pygetset[] = {
+static const PyGetSetDef keydatabin_pygetset[] = {
 #define GETSETNAME(op, name) kdb##op##_##name
   GET  (bin,           "KD.bin -> BYTES")
 #undef GETSETNAME
@@ -595,7 +595,7 @@ static PyTypeObject keydatabin_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydatabin_pygetset,                 /* @tp_getset@ */
+  PYGETSET(keydatabin),                        /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -680,7 +680,7 @@ end:
 
 #define kdeget_ct kdbget_bin
 
-static PyMethodDef keydataenc_pymethods[] = {
+static const PyMethodDef keydataenc_pymethods[] = {
 #define METHNAME(func) kdemeth_##func
   METH (plock,         "KD.plock(TAG) -> ENCRYPTED-KD")
   METH (lock,          "KD.lock(KEY) -> ENCRYPTED-KD")
@@ -690,7 +690,7 @@ static PyMethodDef keydataenc_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef keydataenc_pygetset[] = {
+static const PyGetSetDef keydataenc_pygetset[] = {
 #define GETSETNAME(op, name) kde##op##_##name
   GET  (ct,            "KD.ct -> BYTES")
 #undef GETSETNAME
@@ -730,9 +730,9 @@ static PyTypeObject keydataenc_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  keydataenc_pymethods,                        /* @tp_methods@ */
+  PYMETHODS(keydataenc),               /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydataenc_pygetset,                 /* @tp_getset@ */
+  PYGETSET(keydataenc),                        /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -766,7 +766,7 @@ end:
 static PyObject *kdmget_mp(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(KEYDATA_KD(me)->u.m))); }
 
-static PyGetSetDef keydatamp_pygetset[] = {
+static const PyGetSetDef keydatamp_pygetset[] = {
 #define GETSETNAME(op, name) kdm##op##_##name
   GET  (mp,            "KD.mp -> X")
 #undef GETSETNAME
@@ -808,7 +808,7 @@ static PyTypeObject keydatamp_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydatamp_pygetset,                  /* @tp_getset@ */
+  PYGETSET(keydatamp),                 /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -841,7 +841,7 @@ end:
 static PyObject *kdsget_str(PyObject *me, void *hunoz)
   { return (PyString_FromString(KEYDATA_KD(me)->u.p)); }
 
-static PyGetSetDef keydatastr_pygetset[] = {
+static const PyGetSetDef keydatastr_pygetset[] = {
 #define GETSETNAME(op, name) kds##op##_##name
   GET  (str,           "KD.str -> STRING")
 #undef GETSETNAME
@@ -883,7 +883,7 @@ static PyTypeObject keydatastr_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydatastr_pygetset,                 /* @tp_getset@ */
+  PYGETSET(keydatastr),                        /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -921,7 +921,7 @@ static PyObject *kdeget_ecpt(PyObject *me, void *hunoz)
   return (ecpt_pywrapout(ecpt_pytype, &pt));
 }
 
-static PyGetSetDef keydataec_pygetset[] = {
+static const PyGetSetDef keydataec_pygetset[] = {
 #define GETSETNAME(op, name) kde##op##_##name
   GET  (ecpt,          "KD.ecpt -> ECPT")
 #undef GETSETNAME
@@ -963,7 +963,7 @@ static PyTypeObject keydataec_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keydataec_pygetset,                  /* @tp_getset@ */
+  PYGETSET(keydataec),                 /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1128,7 +1128,7 @@ end:
   return (rc);
 }
 
-static PyMappingMethods keydatastruct_pymapping = {
+static const PyMappingMethods keydatastruct_pymapping = {
   gmap_pysize,                         /* @mp_length@ */
   keydatastruct_pylookup,              /* @mp_subscript@ */
   keydatastruct_pystore                        /* @mp_ass_subscript@ */
@@ -1148,7 +1148,7 @@ static PyTypeObject keydatastruct_pytype_skel = {
   0,                                   /* @tp_repr@ */
   0,                                   /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
-  &keydatastruct_pymapping,            /* @tp_as_mapping@ */
+  PYMAPPING(keydatastruct),            /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
   0,                                   /* @tp_call@ */
   0,                                   /* @tp_str@ */
@@ -1167,7 +1167,7 @@ static PyTypeObject keydatastruct_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   subkeyiter_make,                     /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gmap_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(gmap),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -1314,7 +1314,7 @@ static void keyattrs_pydealloc(PyObject *me)
   FREEOBJ(me);
 }
 
-static PyMappingMethods keyattrs_pymapping = {
+static const PyMappingMethods keyattrs_pymapping = {
   gmap_pysize,                         /* @mp_length@ */
   keyattrs_pylookup,                   /* @mp_subscript@ */
   keyattrs_pystore                     /* @mp_ass_subscript@ */
@@ -1333,8 +1333,8 @@ static PyTypeObject keyattrs_pytype_skel = {
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
   0,                                   /* @tp_as_number@ */
-  &gmap_pysequence,                    /* @tp_as_sequence@ */
-  &keyattrs_pymapping,                 /* @tp_as_mapping@ */
+  PYSEQUENCE(gmap),                    /* @tp_as_sequence@ */
+  PYMAPPING(keyattrs),                 /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
   0,                                   /* @tp_call@ */
   0,                                   /* @tp_str@ */
@@ -1353,7 +1353,7 @@ static PyTypeObject keyattrs_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   keyattriter_make,                    /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gmap_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(gmap),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -1597,7 +1597,7 @@ end:
   return (-1);
 }
 
-static PyMethodDef key_pymethods[] = {
+static const PyMethodDef key_pymethods[] = {
 #define METHNAME(func) kmeth_##func
   METH (delete,        "KEY.delete()")
   METH (expire,        "KEY.expire()")
@@ -1608,7 +1608,7 @@ static PyMethodDef key_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef key_pygetset[] = {
+static const PyGetSetDef key_pygetset[] = {
 #define GETSETNAME(op, name) k##op##_##name
   GET  (file,          "KEY.file -> KF")
   GET  (id,            "KEY.id -> ID")
@@ -1658,9 +1658,9 @@ static PyTypeObject key_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  key_pymethods,                       /* @tp_methods@ */
+  PYMETHODS(key),                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  key_pygetset,                                /* @tp_getset@ */
+  PYGETSET(key),                       /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1990,7 +1990,7 @@ static PyObject *kfget_writep(PyObject *me, void *hunoz)
 static PyObject *kfget_filep(PyObject *me, void *hunoz)
   { return (getbool(!!KEYFILE_KF(me)->fp)); }
 
-static PyMethodDef keyfile_pymethods[] = {
+static const PyMethodDef keyfile_pymethods[] = {
 #define METHNAME(func) kfmeth_##func
   METH (save,          "KF.save()")
   KWMETH(merge,                "KF.merge(FILE, [report = <built-in-reporter>])")
@@ -2005,7 +2005,7 @@ static PyMethodDef keyfile_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef keyfile_pygetset[] = {
+static const PyGetSetDef keyfile_pygetset[] = {
 #define GETSETNAME(op, name) kf##op##_##name
   GET  (name,          "KF.name -> file name")
   GET  (modifiedp,     "KF.modifiedp -> has keyring been modified?")
@@ -2015,7 +2015,7 @@ static PyGetSetDef keyfile_pygetset[] = {
   { 0 }
 };
 
-static PyMappingMethods keyfile_pymapping = {
+static const PyMappingMethods keyfile_pymapping = {
   gmap_pysize,
   keyfile_pylookup,
   0
@@ -2034,8 +2034,8 @@ static PyTypeObject keyfile_pytype_skel = {
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
   0,                                   /* @tp_as_number@ */
-  &gmap_pysequence,                    /* @tp_as_sequence@ */
-  &keyfile_pymapping,                  /* @tp_as_mapping@ */
+  PYSEQUENCE(gmap),                    /* @tp_as_sequence@ */
+  PYMAPPING(keyfile),                  /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
   0,                                   /* @tp_call@ */
   0,                                   /* @tp_str@ */
@@ -2055,9 +2055,9 @@ static PyTypeObject keyfile_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   keyiter_new,                         /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  keyfile_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(keyfile),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keyfile_pygetset,                    /* @tp_getset@ */
+  PYGETSET(keyfile),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
diff --git a/mp.c b/mp.c
index ad68e03..7759e29 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -785,7 +785,7 @@ static PyObject *mpget_noctets(PyObject *me, void *hunoz)
 static PyObject *mpget_noctets2c(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(mp_octets2c(MP_X(me)))); }
 
-static PyGetSetDef mp_pygetset[] = {
+static const PyGetSetDef mp_pygetset[] = {
 #define GETSETNAME(op, func) mp##op##_##func
   GET  (nbits,         "X.nbits -> bit length of X")
   GET  (noctets,       "X.noctets -> octet length of X")
@@ -794,7 +794,7 @@ static PyGetSetDef mp_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef mp_pymethods[] = {
+static const PyMethodDef mp_pymethods[] = {
 #define METHNAME(func) mpmeth_##func
   METH (jacobi,        "X.jacobi(Y) -> Jacobi symbol (Y|X) (NB inversion!)")
   METH (setbit,        "X.setbit(N) -> X with bit N set")
@@ -823,7 +823,7 @@ static PyMethodDef mp_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods mp_pynumber = {
+static const PyNumberMethods mp_pynumber = {
   mp_pyadd,                            /* @nb_add@ */
   mp_pysub,                            /* @nb_subtract@ */
   mp_pymul,                            /* @nb_multiply@ */
@@ -878,7 +878,7 @@ static PyTypeObject mp_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   mp_pycompare,                                /* @tp_compare@ */
   mp_pyrepr,                           /* @tp_repr@ */
-  &mp_pynumber,                                /* @tp_as_number@ */
+  PYNUMBER(mp),                                /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   mp_pyhash,                           /* @tp_hash@ */
@@ -913,9 +913,9 @@ static PyTypeObject mp_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mp_pymethods,                                /* @tp_methods@ */
+  PYMETHODS(mp),                       /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mp_pygetset,                         /* @tp_getset@ */
+  PYGETSET(mp),                                /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1068,14 +1068,14 @@ end:
 static PyObject *mmget_livep(PyObject *me, void *hunoz)
   { return (getbool(MPMUL_LIVEP(me))); }
 
-static PyGetSetDef mpmul_pygetset[] = {
+static const PyGetSetDef mpmul_pygetset[] = {
 #define GETSETNAME(op, name) mm##op##_##name
   GET  (livep,         "MM.livep -> flag: object still valid?")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef mpmul_pymethods[] = {
+static const PyMethodDef mpmul_pymethods[] = {
 #define METHNAME(name) mmmeth_##name
   METH (factor,        "MM.factor(ITERABLE) or MM.factor(I, ...)")
   METH (done,          "MM.done() -> PRODUCT")
@@ -1116,9 +1116,9 @@ static PyTypeObject *mpmul_pytype, mpmul_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mpmul_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(mpmul),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mpmul_pygetset,                      /* @tp_getset@ */
+  PYGETSET(mpmul),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1323,7 +1323,7 @@ static PyObject *mmget_r(PyObject *me, void *hunoz)
 static PyObject *mmget_r2(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(MPMONT_PY(me)->r2))); }
 
-static PyGetSetDef mpmont_pygetset[] = {
+static const PyGetSetDef mpmont_pygetset[] = {
 #define GETSETNAME(op, name) mm##op##_##name
   GET  (m,             "M.m -> modulus for reduction")
   GET  (r,             "M.r -> multiplicative identity")
@@ -1332,7 +1332,7 @@ static PyGetSetDef mpmont_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef mpmont_pymethods[] = {
+static const PyMethodDef mpmont_pymethods[] = {
 #define METHNAME(name) mmmeth_##name
   METH (int,           "M.int(X) -> XR")
   METH (mul,           "M.mul(XR, YR) -> ZR where Z = X Y")
@@ -1383,9 +1383,9 @@ static PyTypeObject *mpmont_pytype, mpmont_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mpmont_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(mpmont),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mpmont_pygetset,                     /* @tp_getset@ */
+  PYGETSET(mpmont),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1471,14 +1471,14 @@ end:
 static PyObject *mbget_m(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(MPBARRETT_PY(me)->m))); }
 
-static PyGetSetDef mpbarrett_pygetset[] = {
+static const PyGetSetDef mpbarrett_pygetset[] = {
 #define GETSETNAME(op, name) mb##op##_##name
   GET  (m,             "B.m -> modulus for reduction")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef mpbarrett_pymethods[] = {
+static const PyMethodDef mpbarrett_pymethods[] = {
 #define METHNAME(name) mbmeth_##name
   METH (reduce,        "B.reduce(X) -> X mod B.m")
   METH (exp,           "B.exp(X, N) -> X^N mod B.m")
@@ -1522,9 +1522,9 @@ static PyTypeObject *mpbarrett_pytype, mpbarrett_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mpbarrett_pymethods,                 /* @tp_methods@ */
+  PYMETHODS(mpbarrett),                        /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mpbarrett_pygetset,                  /* @tp_getset@ */
+  PYGETSET(mpbarrett),                 /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1602,14 +1602,14 @@ end:
 static PyObject *mrget_m(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(MPREDUCE_PY(me)->p))); }
 
-static PyGetSetDef mpreduce_pygetset[] = {
+static const PyGetSetDef mpreduce_pygetset[] = {
 #define GETSETNAME(op, name) mr##op##_##name
   GET  (m,             "R.m -> modulus for reduction")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef mpreduce_pymethods[] = {
+static const const PyMethodDef mpreduce_pymethods[] = {
 #define METHNAME(name) mrmeth_##name
   METH (reduce,        "R.reduce(X) -> X mod B.m")
   METH (exp,           "R.exp(X, N) -> X^N mod B.m")
@@ -1650,9 +1650,9 @@ static PyTypeObject *mpreduce_pytype, mpreduce_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mpreduce_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(mpreduce),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mpreduce_pygetset,                   /* @tp_getset@ */
+  PYGETSET(mpreduce),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1784,7 +1784,7 @@ static PyObject *mcget_moduli(PyObject *me, void *hunoz)
   return (q);
 }
 
-static PyGetSetDef mpcrt_pygetset[] = {
+static const PyGetSetDef mpcrt_pygetset[] = {
 #define GETSETNAME(op, name) mc##op##_##name
   GET  (product,       "C.product -> product of moduli")
   GET  (moduli,        "C.moduli -> list of individual moduli")
@@ -1792,7 +1792,7 @@ static PyGetSetDef mpcrt_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef mpcrt_pymethods[] = {
+static const PyMethodDef mpcrt_pymethods[] = {
 #define METHNAME(name) mcmeth_##name
   METH (solve,         "C.solve([R0, R1]) -> X mod C.product")
 #undef METHNAME
@@ -1832,9 +1832,9 @@ static PyTypeObject *mpcrt_pytype, mpcrt_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  mpcrt_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(mpcrt),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  mpcrt_pygetset,                      /* @tp_getset@ */
+  PYGETSET(mpcrt),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1993,7 +1993,7 @@ static PyObject *gfmeth_irreduciblep(PyObject *me, PyObject *arg)
 static PyObject *gfget_degree(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(mp_bits(MP_X(me)) - 1)); }
 
-static PyGetSetDef gf_pygetset[] = {
+static const PyGetSetDef gf_pygetset[] = {
 #define GETSETNAME(op, name) gf##op##_##name
   GET  (degree,        "X.degree -> polynomial degree of X")
 #undef GETSETNAME
@@ -2004,7 +2004,7 @@ static PyGetSetDef gf_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef gf_pymethods[] = {
+static const PyMethodDef gf_pymethods[] = {
 #define METHNAME(func) gfmeth_##func
   METH (setbit,        "X.setbit(N) -> X with bit N set")
   METH (clearbit,      "X.clearbit(N) -> X with bit N clear")
@@ -2028,7 +2028,7 @@ static PyMethodDef gf_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods gf_pynumber = {
+static const PyNumberMethods gf_pynumber = {
   gf_pyadd,                            /* @nb_add@ */
   gf_pysub,                            /* @nb_subtract@ */
   gf_pymul,                            /* @nb_multiply@ */
@@ -2083,7 +2083,7 @@ static PyTypeObject gf_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   gf_pyrepr,                           /* @tp_repr@ */
-  &gf_pynumber,                                /* @tp_as_number@ */
+  PYNUMBER(gf),                                /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   mp_pyhash,                           /* @tp_hash@ */
@@ -2119,9 +2119,9 @@ static PyTypeObject gf_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gf_pymethods,                                /* @tp_methods@ */
+  PYMETHODS(gf),                       /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gf_pygetset,                         /* @tp_getset@ */
+  PYGETSET(gf),                                /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2278,14 +2278,14 @@ end:
 static PyObject *grget_m(PyObject *me, void *hunoz)
   { return (gf_pywrap(MP_COPY(GFREDUCE_PY(me)->p))); }
 
-static PyGetSetDef gfreduce_pygetset[] = {
+static const PyGetSetDef gfreduce_pygetset[] = {
 #define GETSETNAME(op, name) gr##op##_##name
   GET  (m,             "R.m -> reduction polynomial")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef gfreduce_pymethods[] = {
+static const PyMethodDef gfreduce_pymethods[] = {
 #define METHNAME(name) grmeth_##name
   METH (reduce,        "R.reduce(X) -> X mod B.m")
   METH (trace,        "R.trace(X) -> Tr(X) = x + x^2 + ... + x^{2^{m - 1}}")
@@ -2330,9 +2330,9 @@ static PyTypeObject *gfreduce_pytype, gfreduce_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gfreduce_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gfreduce),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gfreduce_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gfreduce),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2419,7 +2419,7 @@ static void gfn_pydealloc(PyObject *me)
   FREEOBJ(me);
 }
 
-static PyGetSetDef gfn_pygetset[] = {
+static const PyGetSetDef gfn_pygetset[] = {
 #define GETSETNAME(op, name) gfn##op##_##name
   GET  (p,             "X.p -> polynomial basis, as polynomial")
   GET  (beta,          "X.beta -> normal basis element, in poly form")
@@ -2427,7 +2427,7 @@ static PyGetSetDef gfn_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef gfn_pymethods[] = {
+static const PyMethodDef gfn_pymethods[] = {
 #define METHNAME(name) gfnmeth_##name
   METH (pton,          "X.pton(A) -> normal-basis representation of A")
   METH (ntop,          "X.ntop(A) -> polynomial-basis representation of A")
@@ -2469,9 +2469,9 @@ static PyTypeObject gfn_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gfn_pymethods,                       /* @tp_methods@ */
+  PYMETHODS(gfn),                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gfn_pygetset,                                /* @tp_getset@ */
+  PYGETSET(gfn),                       /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2486,7 +2486,7 @@ static PyTypeObject gfn_pytype_skel = {
 
 /*----- Glue --------------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   KWMETH(_MP_fromstring, "fromstring(STR, [radix = 0]) -> (X, REST)\n"
     "  Parse STR as a large integer, according to RADIX.  If RADIX is\n"
index 4c8caf4..d7baf74 100644 (file)
@@ -118,7 +118,7 @@ static PyObject *pixmeth_cancel(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyMethodDef pixie_pymethods[] = {
+static const PyMethodDef pixie_pymethods[] = {
 #define METHNAME(name) pixmeth_##name
   KWMETH(read,         "P.read(TAG, [mode = PMODE_READ]) -> STRING")
   METH (set,           "P.set(TAG, PHRASE)")
@@ -160,7 +160,7 @@ static PyTypeObject pixie_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  pixie_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(pixie),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -220,7 +220,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   KWMETH(ppread,       "ppread(TAG, [mode = PMODE_READ]) -> STRING")
   METH (ppcancel,      "ppcancel(TAG)")
diff --git a/pgen.c b/pgen.c
index 58f6845..dd2d827 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -134,7 +134,7 @@ static PyObject *pfget_x(PyObject *me, void *hunoz)
 static PyObject *pfget_status(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(PFILT_ST(me))); }
 
-static PyGetSetDef pfilt_pygetset[] = {
+static const PyGetSetDef pfilt_pygetset[] = {
 #define GETSETNAME(op, name) pf##op##_##name
   GET  (x,             "F.x -> current position of filter")
   GET  (status,        "F.status -> primality status of filter")
@@ -142,7 +142,7 @@ static PyGetSetDef pfilt_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef pfilt_pymethods[] = {
+static const PyMethodDef pfilt_pymethods[] = {
 #define METHNAME(name) pfmeth_##name
   METH (step,          "F.step(N)")
   METH (muladd,        "F.muladd(M, A)")
@@ -151,7 +151,7 @@ static PyMethodDef pfilt_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods pfilt_pynumber = {
+static const PyNumberMethods pfilt_pynumber = {
   0,                                   /* @nb_add@ */
   0,                                   /* @nb_subtract@ */
   0,                                   /* @nb_multiply@ */
@@ -206,7 +206,7 @@ static PyTypeObject pfilt_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &pfilt_pynumber,                     /* @tp_as_number@ */
+  PYNUMBER(pfilt),                     /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
@@ -227,9 +227,9 @@ static PyTypeObject pfilt_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  pfilt_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(pfilt),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  pfilt_pygetset,                      /* @tp_getset@ */
+  PYGETSET(pfilt),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -311,7 +311,7 @@ static PyObject *meth__RabinMiller_iters(PyObject *me, PyObject *arg)
   return (PyInt_FromLong(rabin_iters(n)));
 }
 
-static PyGetSetDef rabin_pygetset[] = {
+static const PyGetSetDef rabin_pygetset[] = {
 #define GETSETNAME(op, name) r##op##_##name
   GET  (x,             "R.x -> number under test")
   GET  (niters,        "R.niters -> suggested number of tests")
@@ -319,7 +319,7 @@ static PyGetSetDef rabin_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef rabin_pymethods[] = {
+static const PyMethodDef rabin_pymethods[] = {
 #define METHNAME(name) rmeth_##name
   METH (test,          "R.test(W) -> PGST")
   METH (rtest,         "R.rtest(W) -> PGST")
@@ -360,9 +360,9 @@ static PyTypeObject rabin_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  rabin_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(rabin),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  rabin_pygetset,                      /* @tp_getset@ */
+  PYGETSET(rabin),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -453,7 +453,7 @@ end:
   return (rc);
 }
 
-static PyGetSetDef pgevent_pygetset[] = {
+static const PyGetSetDef pgevent_pygetset[] = {
 #define GETSETNAME(op, name) pe##op##_##name
   GET  (name,          "EV.name -> value being generated")
   GETSET(x,            "EV.x -> value under test")
@@ -499,7 +499,7 @@ static PyTypeObject pgevent_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  pgevent_pygetset,                    /* @tp_getset@ */
+  PYGETSET(pgevent),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -631,7 +631,7 @@ PGMETH(fail,        FAIL)
 static PyObject *pgev_stdev(pgen_proc *proc)
   { pgev pg; pg.proc = proc; pg.ctx = 0; return (pgev_pywrap(&pg)); }
 
-static PyMethodDef pgev_pymethods[] = {
+static const PyMethodDef pgev_pymethods[] = {
 #define METHNAME(name) pgmeth_##name
   METH (pg_abort,      "E.pg_abort(EV) -> PGST -- prime generation aborted")
   METH (pg_done,       "E.pg_done(EV) -> PGST -- prime generation finished")
@@ -676,7 +676,7 @@ static PyTypeObject pgev_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  pgev_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(pgev),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -710,7 +710,7 @@ end:
 static PyObject *psget_step(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(PGSTEP_STEP(me))); }
 
-static PyGetSetDef pgstep_pygetset[] = {
+static const PyGetSetDef pgstep_pygetset[] = {
 #define GETSETNAME(op, name) ps##op##_##name
   GET  (step,          "S.step -> step size for the stepper")
 #undef GETSETNAME
@@ -752,7 +752,7 @@ static PyTypeObject pgstep_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  pgstep_pygetset,                     /* @tp_getset@ */
+  PYGETSET(pgstep),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -792,7 +792,7 @@ static void pgjump_pydealloc(PyObject *me)
 static PyObject *pjget_jump(PyObject *me, void *hunoz)
   { RETURN_OBJ(PGJUMP_FOBJ(me)); }
 
-static PyGetSetDef pgjump_pygetset[] = {
+static const PyGetSetDef pgjump_pygetset[] = {
 #define GETSETNAME(op, name) pj##op##_##name
   GET  (jump,          "S.jump -> jump size for the stepper")
 #undef GETSETNAME
@@ -835,7 +835,7 @@ static PyTypeObject pgjump_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  pgjump_pygetset,                     /* @tp_getset@ */
+  PYGETSET(pgjump),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1049,7 +1049,7 @@ end:
 
 /*----- Global stuff ------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   METH (_PrimeFilter_smallfactor, "smallfactor(X) -> PGRC")
   METH (_RabinMiller_iters, "iters(NBITS) -> NITERS")
index ad3bcd4..a557ddb 100644 (file)
--- a/pubkey.c
+++ b/pubkey.c
@@ -188,7 +188,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef dsapub_pymethods[] = {
+static const PyMethodDef dsapub_pymethods[] = {
 #define METHNAME(name) dsameth_##name
   METH (beginhash,     "D.beginhash() -> hash object")
   METH (endhash,       "D.endhash(H) -> BYTES")
@@ -197,14 +197,14 @@ static PyMethodDef dsapub_pymethods[] = {
   { 0 }
 };
 
-static PyMethodDef dsapriv_pymethods[] = {
+static const PyMethodDef dsapriv_pymethods[] = {
 #define METHNAME(name) dsameth_##name
   KWMETH(sign,         "D.sign(MSG, [k = K]) -> R, S")
 #undef METHNAME
   { 0 }
 };
 
-static PyMemberDef dsapub_pymembers[] = {
+static const PyMemberDef dsapub_pymembers[] = {
 #define MEMBERSTRUCT dsa_pyobj
   MEMBER(G,    T_OBJECT, READONLY, "D.G -> group to work in")
   MEMBER(p,    T_OBJECT, READONLY, "D.p -> public key (group element")
@@ -214,7 +214,7 @@ static PyMemberDef dsapub_pymembers[] = {
   { 0 }
 };
 
-static PyMemberDef dsapriv_pymembers[] = {
+static const PyMemberDef dsapriv_pymembers[] = {
 #define MEMBERSTRUCT dsa_pyobj
   MEMBER(u,    T_OBJECT, READONLY, "D.u -> private key (exponent)")
 #undef MEMBERSTRUCT
@@ -254,8 +254,8 @@ static PyTypeObject dsapub_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  dsapub_pymethods,                    /* @tp_methods@ */
-  dsapub_pymembers,                    /* @tp_members@ */
+  PYMETHODS(dsapub),                   /* @tp_methods@ */
+  PYMEMBERS(dsapub),                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -303,8 +303,8 @@ static PyTypeObject dsapriv_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  dsapriv_pymethods,                   /* @tp_methods@ */
-  dsapriv_pymembers,                   /* @tp_members@ */
+  PYMETHODS(dsapriv),                  /* @tp_methods@ */
+  PYMEMBERS(dsapriv),                  /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -426,7 +426,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef kcdsapub_pymethods[] = {
+static const PyMethodDef kcdsapub_pymethods[] = {
 #define METHNAME(name) kcdsameth_##name
   METH (beginhash,     "D.beginhash() -> hash object")
   METH (endhash,       "D.endhash(H) -> BYTES")
@@ -435,7 +435,7 @@ static PyMethodDef kcdsapub_pymethods[] = {
   { 0 }
 };
 
-static PyMethodDef kcdsapriv_pymethods[] = {
+static const PyMethodDef kcdsapriv_pymethods[] = {
 #define METHNAME(name) kcdsameth_##name
   KWMETH(sign,         "D.sign(MSG, [k = K]) -> R, S")
 #undef METHNAME
@@ -475,8 +475,8 @@ static PyTypeObject kcdsapub_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  kcdsapub_pymethods,                  /* @tp_methods@ */
-  dsapub_pymembers,                    /* @tp_members@ */
+  PYMETHODS(kcdsapub),                 /* @tp_methods@ */
+  PYMEMBERS(dsapub),                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -524,8 +524,8 @@ static PyTypeObject kcdsapriv_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  kcdsapriv_pymethods,                 /* @tp_methods@ */
-  dsapriv_pymembers,                   /* @tp_members@ */
+  PYMETHODS(kcdsapriv),                        /* @tp_methods@ */
+  PYMEMBERS(dsapriv),                  /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -757,7 +757,7 @@ end:
   return (rc);
 }
 
-static PyGetSetDef rsapub_pygetset[] = {
+static const PyGetSetDef rsapub_pygetset[] = {
 #define GETSETNAME(op, name) rsa##op##_##name
   GET  (n,             "R.n -> N")
   GET  (e,             "R.e -> E")
@@ -765,14 +765,14 @@ static PyGetSetDef rsapub_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef rsapub_pymethods[] = {
+static const PyMethodDef rsapub_pymethods[] = {
 #define METHNAME(name) rsameth_##name
   METH (pubop,         "R.pubop(X) -> X^E (mod N)")
 #undef METHNAME
   { 0 }
 };
 
-static PyGetSetDef rsapriv_pygetset[] = {
+static const PyGetSetDef rsapriv_pygetset[] = {
 #define GETSETNAME(op, name) rsa##op##_##name
   GET  (d,             "R.d -> D")
   GET  (p,             "R.p -> P")
@@ -785,7 +785,7 @@ static PyGetSetDef rsapriv_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef rsapriv_pymethods[] = {
+static const PyMethodDef rsapriv_pymethods[] = {
 #define METHNAME(name) rsameth_##name
   KWMETH(privop,       "R.privop(X, [rng = None]) -> X^D (mod N)")
 #undef METHNAME
@@ -825,9 +825,9 @@ static PyTypeObject rsapub_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  rsapub_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(rsapub),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  rsapub_pygetset,                     /* @tp_getset@ */
+  PYGETSET(rsapub),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -874,9 +874,9 @@ static PyTypeObject rsapriv_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  rsapriv_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(rsapriv),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  rsapriv_pygetset,                    /* @tp_getset@ */
+  PYGETSET(rsapriv),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1261,7 +1261,7 @@ EDDSAS(DEFEDDSA)
 
 /*----- Global stuff ------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   KWMETH(_p1crypt_encode, 0)
   KWMETH(_p1crypt_decode, 0)
index 229dfa9..615c5ed 100644 (file)
@@ -160,7 +160,7 @@ static PyTypeObject valiter_pytype_skel = {
   0                                    /* @tp_is_gc@ */
 };
 
-PySequenceMethods gmap_pysequence = {
+const PySequenceMethods gmap_pysequence = {
   0,                                   /* @sq_length@ */
   0,                                   /* @sq_concat@ */
   0,                                   /* @sq_repeat@ */
@@ -403,7 +403,7 @@ end:
   return (rc);
 }
 
-PyMethodDef gmap_pymethods[] = {
+const PyMethodDef gmap_pymethods[] = {
   GMAP_METHODS
   { 0 }
 };
index 883223a..b462a1f 100644 (file)
@@ -260,7 +260,7 @@ PyTypeObject *inittype(PyTypeObject *tyskel, PyTypeObject *meta)
 /*----- Populating modules ------------------------------------------------*/
 
 PyObject *mkexc(PyObject *mod, PyObject *base,
-               const char *name, PyMethodDef *mm)
+               const char *name, const PyMethodDef *mm)
 {
   PyObject *nameobj = 0;
   PyObject *dict = 0;
@@ -272,7 +272,8 @@ PyObject *mkexc(PyObject *mod, PyObject *base,
 
   if (mm) {
     while (mm->ml_name) {
-      if ((func = PyCFunction_NewEx(mm, 0, mod)) == 0 ||
+      if ((func = PyCFunction_NewEx((/*unconst*/ PyMethodDef *)mm,
+                                   0, mod)) == 0 ||
          (meth = PyMethod_New(func, 0, exc)) == 0 ||
          PyDict_SetItemString(dict, mm->ml_name, meth))
        goto fail;
index b91b48d..e200c09 100644 (file)
@@ -269,6 +269,20 @@ extern PyTypeObject *inittype(PyTypeObject */*skel*/,
 #define MEMBER(name, ty, f, doc)                                       \
   { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },
 
+/* Wrappers for filling in pointers in a `PyTypeObject' structure, (a)
+ * following Pyke naming convention, and (b) stripping `const' from the types
+ * without losing type safety.
+ */
+#define UNCONST_TYPE_SLOT(type, suffix, op, ty)                                \
+  CONVERT_CAREFULLY(type *, const type *, op ty##_py##suffix)
+#define PYGETSET(ty) UNCONST_TYPE_SLOT(PyGetSetDef, getset, NOTHING, ty)
+#define PYMETHODS(ty) UNCONST_TYPE_SLOT(PyMethodDef, methods, NOTHING, ty)
+#define PYMEMBERS(ty) UNCONST_TYPE_SLOT(PyMemberDef, members, NOTHING, ty)
+#define PYNUMBER(ty) UNCONST_TYPE_SLOT(PyNumberMethods, number, &, ty)
+#define PYSEQUENCE(ty) UNCONST_TYPE_SLOT(PySequenceMethods, sequence, &, ty)
+#define PYMAPPING(ty) UNCONST_TYPE_SLOT(PyMappingMethods, mapping, &, ty)
+#define PYBUFFER(ty) UNCONST_TYPE_SLOT(PyBufferProcs, buffer, &, ty)
+
 /*----- Populating modules ------------------------------------------------*/
 
 extern PyObject *modname;
@@ -278,7 +292,7 @@ extern PyObject *home_module;
   /* The overall module object. */
 
 extern PyObject *mkexc(PyObject */*mod*/, PyObject */*base*/,
-                      const char */*name*/, PyMethodDef */*methods*/);
+                      const char */*name*/, const PyMethodDef */*methods*/);
   /* Make and return an exception class called NAME, which will end up in
    * module MOD (though it is not added at this time).  The new class is a
    * subclass of BASE.  Attach the METHODS to it.
@@ -376,8 +390,8 @@ GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL)
 
 /* Mapping protocol implementation. */
 extern Py_ssize_t gmap_pysize(PyObject *); /* for `mp_length' */
-extern PySequenceMethods gmap_pysequence; /* for `tp_as_sequence' */
-extern PyMethodDef gmap_pymethods[]; /* all the standard methods */
+extern const PySequenceMethods gmap_pysequence; /* for `tp_as_sequence' */
+extern const PyMethodDef gmap_pymethods[]; /* all the standard methods */
 
 /*----- That's all, folks -------------------------------------------------*/
 
diff --git a/rand.c b/rand.c
index 5286472..9e7539c 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -259,7 +259,7 @@ static PyObject *grget_name(PyObject *me, void *hunoz)
 static PyObject *grget_cryptop(PyObject *me, void *hunoz)
   { return (grand_check(me) ? 0 : getbool(GRAND_R(me)->ops->f & GRAND_CRYPTO)); }
 
-static PyGetSetDef grand_pygetset[] = {
+static const PyGetSetDef grand_pygetset[] = {
 #define GETSETNAME(op, name) gr##op##_##name
   GET  (name,          "R.name -> name of this kind of generator")
   GET  (cryptop,       "R.cryptop -> flag: cryptographically strong?")
@@ -267,7 +267,7 @@ static PyGetSetDef grand_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef grand_pymethods[] = {
+static const PyMethodDef grand_pymethods[] = {
 #define METHNAME(name) grmeth_##name
   METH (byte,          "R.byte() -> BYTE")
   METH (word,          "R.word() -> WORD")
@@ -317,9 +317,9 @@ static PyTypeObject grand_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  grand_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(grand),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  grand_pygetset,                      /* @tp_getset@ */
+  PYGETSET(grand),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -518,7 +518,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef truerand_pymethods[] = {
+static const PyMethodDef truerand_pymethods[] = {
 #define METHNAME(name) trmeth_##name
   METH (gate,          "R.gate()")
   METH (stretch,       "R.stretch()")
@@ -536,7 +536,7 @@ static PyObject *trget_goodbits(PyObject *me, void *hunoz)
   return (PyInt_FromLong(r->ops->misc(r, RAND_GOODBITS)));
 }
 
-static PyGetSetDef truerand_pygetset[] = {
+static const PyGetSetDef truerand_pygetset[] = {
 #define GETSETNAME(op, name) tr##op##_##name
   GET  (goodbits,      "R.goodbits -> good bits of entropy remaining")
 #undef GETSETNAME
@@ -576,9 +576,9 @@ static PyTypeObject truerand_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  truerand_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(truerand),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  truerand_pygetset,                   /* @tp_getset@ */
+  PYGETSET(truerand),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -776,7 +776,7 @@ static PyObject *gclrmeth_seek(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyGetSetDef gccrand_pygetset[] = {
+static const PyGetSetDef gccrand_pygetset[] = {
 #define GETSETNAME(op, name) gccr##op##_##name
   GET  (keysz,         "CR.keysz -> acceptable key sizes")
   GET  (name,          "CR.name -> name of this kind of generator")
@@ -784,7 +784,7 @@ static PyGetSetDef gccrand_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef gclatinrand_pymethods[] = {
+static const PyMethodDef gclatinrand_pymethods[] = {
 #define METHNAME(name) gclrmeth_##name
   METH (tell,          "R.tell() -> OFF")
   METH (seek,          "R.seek(OFF)")
@@ -827,7 +827,7 @@ static PyTypeObject gccrand_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gccrand_pygetset,                    /* @tp_getset@ */
+  PYGETSET(gccrand),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -921,7 +921,7 @@ static PyTypeObject gclatinrand_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gclatinrand_pymethods,               /* @tp_methods@ */
+  PYMETHODS(gclatinrand),              /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -1161,7 +1161,7 @@ static PyObject *drget_seed(PyObject *me, void *hunoz)
   return (rc);
 }
 
-static PyGetSetDef dsarand_pygetset[] = {
+static const PyGetSetDef dsarand_pygetset[] = {
 #define GETSETNAME(op, name) dr##op##_##name
   GET  (seed,          "R.seed -> current generator seed")
 #undef GETSETNAME
@@ -1203,7 +1203,7 @@ static PyTypeObject dsarand_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  dsarand_pygetset,                    /* @tp_getset@ */
+  PYGETSET(dsarand),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1282,7 +1282,7 @@ static PyObject *bbsget_stepsz(PyObject *me, void *hunoz)
   return (PyInt_FromLong(r->ops->misc(r, BBS_STEPSZ)));
 }
 
-static PyMethodDef bbs_pymethods[] = {
+static const PyMethodDef bbs_pymethods[] = {
 #define METHNAME(name) bbsmeth_##name
   METH (step,          "R.step(): steps the generator (not useful)")
   METH (bits,   "R.bits(N) -> W: returns N bits (<= 32) from the generator")
@@ -1291,7 +1291,7 @@ static PyMethodDef bbs_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef bbs_pygetset[] = {
+static const PyGetSetDef bbs_pygetset[] = {
 #define GETSETNAME(op, name) bbs##op##_##name
   GET  (n,             "R.n -> Blum modulus")
   GETSET(x,            "R.x -> current seed value")
@@ -1333,9 +1333,9 @@ static PyTypeObject bbs_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  bbs_pymethods,                       /* @tp_methods@ */
+  PYMETHODS(bbs),                      /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  bbs_pygetset,                                /* @tp_getset@ */
+  PYGETSET(bbs),                       /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1444,7 +1444,7 @@ static PyObject *bpget_p(PyObject *me, void *hunoz)
 static PyObject *bpget_q(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(BBSPRIV_BP(me)->q))); }
 
-static PyMethodDef bbspriv_pymethods[] = {
+static const PyMethodDef bbspriv_pymethods[] = {
 #define METHNAME(name) bpmeth_##name
   METH (ff,            "R.ff(N): fast-forward N places")
   METH (rew,           "R.rew(N): rewind N places")
@@ -1452,7 +1452,7 @@ static PyMethodDef bbspriv_pymethods[] = {
   { 0 }
 };
 
-static PyGetSetDef bbspriv_pygetset[] = {
+static const PyGetSetDef bbspriv_pygetset[] = {
 #define GETSETNAME(op, name) bp##op##_##name
   GET  (n,             "R.n -> Blum modulus")
   GET  (p,             "R.p -> one of the factors of the modulus")
@@ -1495,9 +1495,9 @@ static PyTypeObject bbspriv_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  bbspriv_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(bbspriv),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  bbspriv_pygetset,                    /* @tp_getset@ */
+  PYGETSET(bbspriv),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1512,7 +1512,7 @@ static PyTypeObject bbspriv_pytype_skel = {
 
 /*----- Global stuff ------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   KWMETH(_BBSPriv_generate, "generate(NBITS, [event = pgen_nullev], "
                              "[rng = rand], [nsteps = 0], [seed = 2]) -> R")
diff --git a/share.c b/share.c
index 342144e..16d376e 100644 (file)
--- a/share.c
+++ b/share.c
@@ -53,7 +53,7 @@ static PyObject *gfsget_threshold(PyObject *me, void *hunoz)
 static PyObject *gfsget_size(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GFSHARE_S(me)->sz)); }
 
-static PyGetSetDef gfshare_pygetset[]= {
+static const PyGetSetDef gfshare_pygetset[]= {
 #define GETSETNAME(op, name) gfs##op##_##name
   GET  (threshold,     "S.threshold -> THRESHOLD")
   GET  (size,          "S.size -> SECRETSZ")
@@ -96,7 +96,7 @@ static PyTypeObject gfshare_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gfshare_pygetset,                    /* @tp_getset@ */
+  PYGETSET(gfshare),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -142,7 +142,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef gfsharesplit_pymethods[] = {
+static const PyMethodDef gfsharesplit_pymethods[] = {
 #define METHNAME(name) gfsmeth_##name
   METH (get,           "S.get(I) -> SHARE")
 #undef METHNAME
@@ -183,7 +183,7 @@ static PyTypeObject gfsharesplit_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gfsharesplit_pymethods,              /* @tp_methods@ */
+  PYMETHODS(gfsharesplit),             /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -252,7 +252,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef gfsharejoin_pymethods[] = {
+static const PyMethodDef gfsharejoin_pymethods[] = {
 #define METHNAME(name) gfsmeth_##name
   METH (addedp,        "S.addedp(I) -> BOOL")
   METH (add,           "S.add(I, SHARE) -> REMAIN")
@@ -264,7 +264,7 @@ static PyMethodDef gfsharejoin_pymethods[] = {
 static PyObject *gfsget_remain(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GFSHARE_S(me)->t - GFSHARE_S(me)->i)); }
 
-static PyGetSetDef gfsharejoin_pygetset[]= {
+static const PyGetSetDef gfsharejoin_pygetset[]= {
 #define GETSETNAME(op, name) gfs##op##_##name
   GET  (remain,        "S.remain -> REMAIN")
 #undef GETSETNAME
@@ -305,9 +305,9 @@ static PyTypeObject gfsharejoin_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gfsharejoin_pymethods,               /* @tp_methods@ */
+  PYMETHODS(gfsharejoin),              /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gfsharejoin_pygetset,                        /* @tp_getset@ */
+  PYGETSET(gfsharejoin),               /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -345,7 +345,7 @@ static PyObject *sget_threshold(PyObject *me, void *hunoz)
 static PyObject *sget_modulus(PyObject *me, void *hunoz)
   { return (mp_pywrap(SHARE_S(me)->p)); }
 
-static PyGetSetDef share_pygetset[]= {
+static const PyGetSetDef share_pygetset[]= {
 #define GETSETNAME(op, name) s##op##_##name
   GET  (threshold,     "S.threshold -> THRESHOLD")
   GET  (modulus,       "S.modulus -> MODULUS")
@@ -388,7 +388,7 @@ static PyTypeObject share_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  share_pygetset,                      /* @tp_getset@ */
+  PYGETSET(share),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -439,7 +439,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef sharesplit_pymethods[] = {
+static const PyMethodDef sharesplit_pymethods[] = {
 #define METHNAME(name) smeth_##name
   METH (get,           "S.get(I) -> SHARE")
 #undef METHNAME
@@ -480,7 +480,7 @@ static PyTypeObject sharesplit_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  sharesplit_pymethods,                        /* @tp_methods@ */
+  PYMETHODS(sharesplit),               /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -551,7 +551,7 @@ end:
   return (rc);
 }
 
-static PyMethodDef sharejoin_pymethods[] = {
+static const PyMethodDef sharejoin_pymethods[] = {
 #define METHNAME(name) smeth_##name
   METH (addedp,        "S.addedp(I) -> BOOL")
   METH (add,           "S.add(I, SHARE) -> REMAIN")
@@ -563,7 +563,7 @@ static PyMethodDef sharejoin_pymethods[] = {
 static PyObject *sget_remain(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(SHARE_S(me)->t - SHARE_S(me)->i)); }
 
-static PyGetSetDef sharejoin_pygetset[]= {
+static const PyGetSetDef sharejoin_pygetset[]= {
 #define GETSETNAME(op, name) s##op##_##name
   GET  (remain,        "S.remain -> REMAIN")
 #undef GETSETNAME
@@ -604,9 +604,9 @@ static PyTypeObject sharejoin_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  sharejoin_pymethods,                 /* @tp_methods@ */
+  PYMETHODS(sharejoin),                        /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  sharejoin_pygetset,                  /* @tp_getset@ */
+  PYGETSET(sharejoin),                 /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */