X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/6d481bc65d194c9ef8445d622b7ce85eadc46921..ab723d7332a553a47c78f33229e402a0b3618744:/field.c diff --git a/field.c b/field.c index f17f4d9..5b4c27d 100644 --- a/field.c +++ b/field.c @@ -66,7 +66,7 @@ static PyObject *field_dopywrap(PyTypeObject *ty, field *f) 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); + typeready(&fobj->ty.ht_type); return ((PyObject *)fobj); } @@ -229,15 +229,7 @@ end: } static long fe_pyhash(PyObject *me) -{ - size_t sz = FE_F(me)->noctets; - uint32 h = 0xe0c127ca + FE_F(me)->ops->ty; - octet *p = xmalloc(sz); - mp_storeb(FE_X(me), p, sz); - h = unihash_hash(&unihash_global, h, p, sz); - xfree(p); - return (h % LONG_MAX); -} + { return (mphash(FE_X(me))); } static int fe_pycoerce(PyObject **x, PyObject **y) { @@ -263,10 +255,12 @@ end: static PyObject *fe_pyint(PyObject *x) { long l; + PyObject *rc; mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x)); - if (mp_tolong_checked(xx, &l)) { MP_DROP(xx); return (0); } + if (!mp_tolong_checked(xx, &l, 0)) rc = PyInt_FromLong(l); + else rc = mp_topylong(xx); MP_DROP(xx); - return (PyInt_FromLong(l)); + return (rc); } static PyObject *fe_pylong(PyObject *x) @@ -958,7 +952,7 @@ static PyObject *meth__Field_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if ((f = field_parse(&qd)) == 0) - SYNERR(qd.e); + VALERR(qd.e); rc = Py_BuildValue("(Ns)", field_pywrap(f), qd.p); end: return (rc);