From 162bd8a25051fae1b54789261191fde644be77e0 Mon Sep 17 00:00:00 2001
From: zooko <zooko@zooko.com>
Date: Fri, 26 Jan 2007 02:54:01 +0530
Subject: [PATCH] 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
---
 pyfec/fec/fecmodule.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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);
-- 
2.45.2