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;
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);
}
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);
}
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);
}
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);
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)) {
/*----- Glue --------------------------------------------------------------*/
+static const struct nameval consts[] = {
+ CONST(MPW_MAX),
+ { 0 }
+};
+
void mp_pyinit(void)
{
INITTYPE(mp, root);
INSERT("GF", gf_pytype);
INSERT("GFReduce", gfreduce_pytype);
INSERT("GFN", gfn_pytype);
+ setconstants(mod, consts);
}
/*----- That's all, folks -------------------------------------------------*/