From: zooko Date: Thu, 25 Jan 2007 21:24:01 +0000 (+0530) Subject: use buffers as generic "read" buffers instead of char buffers X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/simplejson/encoder.py.html?a=commitdiff_plain;h=162bd8a25051fae1b54789261191fde644be77e0;p=tahoe-lafs%2Fzfec.git use buffers as generic "read" buffers instead of char buffers This is a typing kludge -- if your buffers have elements of size > 1 then we will be processing only a subset of the elements and treating each byte of the element as a separate entry. Oh well. darcs-hash:27942744df0e8649a69e23bf0d42e18725391b19 --- diff --git a/pyfec/fec/fecmodule.c b/pyfec/fec/fecmodule.c index cc7711c..304aed4 100644 --- a/pyfec/fec/fecmodule.c +++ b/pyfec/fec/fecmodule.c @@ -152,7 +152,7 @@ Encoder_encode(Encoder *self, PyObject *args) { py_raise_fec_error("Precondition violation: %u'th item is required to offer the single-segment read character buffer protocol, but it does not.\n", i); goto err; } - if (PyObject_AsCharBuffer(fastinsharesitems[i], &(incshares[i]), &sz)) + if (PyObject_AsReadBuffer(fastinsharesitems[i], &(incshares[i]), &sz)) goto err; if (oldsz != 0 && oldsz != sz) { py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz); @@ -385,9 +385,11 @@ Decoder_decode(Decoder *self, PyObject *args) { if (csharenums[i] >= self->kk) needtorecover+=1; - if (!PyObject_CheckReadBuffer(fastsharesitems[i])) + if (!PyObject_CheckReadBuffer(fastsharesitems[i])) { + py_raise_fec_error("Precondition violation: %u'th item is required to offer the single-segment read character buffer protocol, but it does not.\n", i); goto err; - if (PyObject_AsCharBuffer(fastsharesitems[i], &(cshares[i]), &sz)) + } + if (PyObject_AsReadBuffer(fastsharesitems[i], &(cshares[i]), &sz)) goto err; if (oldsz != 0 && oldsz != sz) { py_raise_fec_error("Precondition violation: Input shares are required to be all the same length. oldsz: %Zu, sz: %Zu\n", oldsz, sz);