unsigned c_desired_shares_ids[self->mm];
unsigned c_desired_checkshares_ids[self->mm - self->kk];
unsigned i;
+ PyObject* fastinshares = NULL;
+
for (i=0; i<self->mm - self->kk; i++)
pystrs_produced[i] = NULL;
if (desired_shares_ids) {
fast_desired_shares_ids = PySequence_Fast(desired_shares_ids, "Second argument (optional) was not a sequence.");
+ if (!fast_desired_shares_ids)
+ goto err;
num_desired_shares = PySequence_Fast_GET_SIZE(fast_desired_shares_ids);
fast_desired_shares_ids_items = PySequence_Fast_ITEMS(fast_desired_shares_ids);
for (i=0; i<num_desired_shares; i++) {
num_check_shares_produced = self->mm - self->kk;
}
- PyObject* fastinshares = PySequence_Fast(inshares, "First argument was not a sequence.");
+ fastinshares = PySequence_Fast(inshares, "First argument was not a sequence.");
if (!fastinshares)
goto err;
def test_bad_args_enc():
encer = fec.Encoder(2, 4)
try:
- encer.encode(["a", "b", ], ["c", "d",])
+ encer.encode(["a", "b", ], ["c", "I am not an integer shareid",])
except fec.Error, e:
- assert "econd argument is required to contain int" in str(e), e
+ assert "Precondition violation: second argument is required to contain int" in str(e), e
else:
raise "Should have gotten fec.Error for wrong type of second argument."
+ try:
+ encer.encode(["a", "b", ], 98) # not a sequence at all
+ except TypeError, e:
+ assert "Second argument (optional) was not a sequence" in str(e), e
+ else:
+ raise "Should have gotten TypeError for wrong type of second argument."
+
def test_bad_args_dec():
decer = fec.Decoder(2, 4)
+
+ try:
+ decer.decode(98, [0, 1]) # first argument is not a sequence
+ except TypeError, e:
+ assert "First argument was not a sequence" in str(e), e
+ else:
+ raise "Should have gotten TypeError for wrong type of second argument."
+
try:
decer.decode(["a", "b", ], ["c", "d",])
except fec.Error, e:
- assert "econd argument is required to contain int" in str(e), e
+ assert "Precondition violation: second argument is required to contain int" in str(e), e
else:
raise "Should have gotten fec.Error for wrong type of second argument."
+
+ try:
+ decer.decode(["a", "b", ], 98) # not a sequence at all
+ except TypeError, e:
+ assert "Second argument was not a sequence" in str(e), e
+ else:
+ raise "Should have gotten TypeError for wrong type of second argument."
if __name__ == "__main__":