static PyObject *ty##meth_frombuf(PyObject *me, PyObject *arg) \
{ \
buf b; \
- char *p; \
- Py_ssize_t sz; \
+ struct bin in; \
PyObject *rc = 0; \
mp *x; \
\
- if (!PyArg_ParseTuple(arg, "s#:frombuf", &p, &sz)) goto end; \
- buf_init(&b, p, sz); \
+ if (!PyArg_ParseTuple(arg, "O&:frombuf", convbin, &in)) goto end; \
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz); \
if ((x = buf_getmp(&b)) == 0) VALERR("malformed data"); \
rc = Py_BuildValue("(NN)", ty##_pywrap(x), \
bytestring_pywrapbuf(&b)); \
#define LOADOP(pre, name) \
static PyObject *pre##meth_##name(PyObject *me, PyObject *arg) \
{ \
- char *p; \
- Py_ssize_t len; \
- if (!PyArg_ParseTuple(arg, "s#:" #name, &p, &len)) return (0); \
- return (pre##_pywrap(mp_##name(MP_NEW, p, len))); \
+ struct bin in; \
+ if (!PyArg_ParseTuple(arg, "O&:" #name, convbin, &in)) return (0); \
+ return (pre##_pywrap(mp_##name(MP_NEW, in.p, in.sz))); \
}
LOADOP(mp, loadl)
LOADOP(mp, loadb)