*.c: Use the new `Py_TYPE' and `Py_SIZE' macros; define them if necessary.
[catacomb-python] / mp.c
diff --git a/mp.c b/mp.c
index 2f8594d..1513974 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -45,12 +45,12 @@ mp *mp_frompylong(PyObject *obj)
   mp *x;
   mpw *p;
 
-  sz = l->ob_size;
+  sz = Py_SIZE(l);
   if (sz < 0) sz = -sz;
   assert(MPW_BITS >= SHIFT);
   bits = (unsigned long)sz * SHIFT;
   w = (bits + MPW_BITS - 1)/MPW_BITS;
-  x = mp_new(w, l->ob_size < 0 ? MP_NEG : 0);
+  x = mp_new(w, Py_SIZE(l) < 0 ? MP_NEG : 0);
   p = x->v;
   for (i = 0; i < sz; i++) {
     r |= (mpd)l->ob_digit[i] << b;
@@ -94,7 +94,7 @@ PyObject *mp_topylong(mp *x)
     l->ob_digit[i++] = r & MASK;
     r >>= SHIFT;
   }
-  l->ob_size = (x->f & MP_NEG) ? -sz : sz;
+  Py_SIZE(l) = (x->f & MP_NEG) ? -sz : sz;
   return ((PyObject *)l);
 }
 
@@ -238,7 +238,7 @@ mp *getmp(PyObject *o)
   if (!o) return (0);
   if ((x = tomp(o)) == 0) {
     PyErr_Format(PyExc_TypeError, "can't convert %.100s to mp",
-                o->ob_type->tp_name);
+                Py_TYPE(o)->tp_name);
   }
   return (x);
 }
@@ -257,7 +257,7 @@ mp *getgf(PyObject *o)
   if (!o) return (0);
   if ((x = tomp(o)) == 0) {
     PyErr_Format(PyExc_TypeError, "can't convert %.100s to gf",
-                o->ob_type->tp_name);
+                Py_TYPE(o)->tp_name);
   }
   return (x);
 }
@@ -536,7 +536,7 @@ static PyObject *mp_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   if (!good_radix_p(radix, 1)) VALERR("bad radix");
   if ((z = mp_frompyobject(x, radix)) == 0) {
     PyErr_Format(PyExc_TypeError, "can't convert %.100s to mp",
-                x->ob_type->tp_name);
+                Py_TYPE(x)->tp_name);
     goto end;
   }
   zz = (mp_pyobj *)ty->tp_alloc(ty, 0);
@@ -1907,7 +1907,7 @@ static PyObject *gf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   if (!good_radix_p(radix, 1)) VALERR("radix out of range");
   if ((z = mp_frompyobject(x, radix)) == 0) {
     PyErr_Format(PyExc_TypeError, "can't convert %.100s to gf",
-                x->ob_type->tp_name);
+                Py_TYPE(x)->tp_name);
     goto end;
   }
   if (MP_NEGP(z)) {