X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/f368b46e168e8accdb0c578ccbba7e7d2ee8c0de..9ca1789eac7b1e6be29918e033b66d6328883575:/field.c diff --git a/field.c b/field.c index bb99b77..9f51f5f 100644 --- a/field.c +++ b/field.c @@ -58,17 +58,17 @@ static PyObject *field_dopywrap(PyTypeObject *ty, field *f) { field_pyobj *fobj = newtype(ty, 0, f->ops->name); fobj->f = f; - fobj->ty.type.tp_basicsize = sizeof(fe_pyobj); - fobj->ty.type.tp_base = fe_pytype; + fobj->ty.ht_type.tp_basicsize = sizeof(fe_pyobj); + fobj->ty.ht_type.tp_base = fe_pytype; Py_INCREF(fe_pytype); - fobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_HEAPTYPE); - fobj->ty.type.tp_alloc = PyType_GenericAlloc; - fobj->ty.type.tp_free = 0; - fobj->ty.type.tp_new = fe_pynew; - PyType_Ready(&fobj->ty.type); + fobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_HEAPTYPE); + fobj->ty.ht_type.tp_alloc = PyType_GenericAlloc; + fobj->ty.ht_type.tp_free = 0; + fobj->ty.ht_type.tp_new = fe_pynew; + PyType_Ready(&fobj->ty.ht_type); return ((PyObject *)fobj); } @@ -115,16 +115,16 @@ static mp *tofe(field *f, PyObject *o) if (FE_PYCHECK(o)) { if (FE_F(o) != f && !field_samep(FE_F(o), f)) return (0); - y = FE_X(o); - } - if ((x = tomp(o)) != 0) { + y = MP_COPY(FE_X(o)); + } else if ((x = tomp(o)) != 0) { if (MP_ZEROP(x)) - y = f->zero; + y = MP_COPY(f->zero); else if (MP_EQ(x, MP_ONE)) - y = f->one; + y = MP_COPY(f->one); + else + y = F_IN(f, MP_NEW, x); + MP_DROP(x); } - if (x) MP_DROP(x); - if (y) MP_COPY(y); return (y); }