From: Zooko O'Whielacronx Date: Thu, 25 Jan 2007 22:24:01 +0000 (-0700) Subject: use buffers as generic "read" buffers instead of char buffers X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~320 X-Git-Url: https://git.rkrishnan.org/specifications/components/com_hotproperty/configuration.rst?a=commitdiff_plain;h=b4f30afe3d9ae24fd15957ebdd562007470606dc;p=tahoe-lafs%2Ftahoe-lafs.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. --- diff --git a/pyfec/fec/fecmodule.c b/pyfec/fec/fecmodule.c index 79edc409..c7ed0b82 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);