diff -rN -u old-1.8.2/src/allmydata/immutable/encode.py new-1.8.2/src/allmydata/immutable/encode.py --- old-1.8.2/src/allmydata/immutable/encode.py 2011-06-21 11:54:33.015220996 -0600 +++ new-1.8.2/src/allmydata/immutable/encode.py 2011-06-21 11:54:33.187220996 -0600 @@ -105,6 +105,7 @@ def _got_size(size): self.log(format="file size: %(size)d", size=size) self.file_size = size + precondition(isinstance(self.file_size, (int, long)), self.file_size) d.addCallback(_got_size) d.addCallback(lambda res: eu.get_all_encoding_parameters()) d.addCallback(self._got_all_encoding_parameters) @@ -118,6 +119,7 @@ def _got_all_encoding_parameters(self, params): assert not self._codec k, happy, n, segsize = params + precondition(isinstance(segsize, (int, long)), segsize) self.required_shares = k self.servers_of_happiness = happy self.num_shares = n @@ -129,6 +131,7 @@ self.num_segments = mathutil.div_ceil(self.file_size, self.segment_size) + precondition(isinstance(self.num_segments, (int, long)), self.num_segments) self._codec = CRSEncoder() self._codec.set_params(self.segment_size, diff -rN -u old-1.8.2/src/allmydata/immutable/upload.py new-1.8.2/src/allmydata/immutable/upload.py --- old-1.8.2/src/allmydata/immutable/upload.py 2011-06-21 11:54:33.025220996 -0600 +++ new-1.8.2/src/allmydata/immutable/upload.py 2011-06-21 11:54:33.188220996 -0600 @@ -608,6 +608,7 @@ d = self.original.get_all_encoding_parameters() def _got(encoding_parameters): (k, happy, n, segsize) = encoding_parameters + precondition(isinstance(segsize, (int, long)), segsize) self._segment_size = segsize # used by segment hashers self._encoding_parameters = encoding_parameters self.log("my encoding parameters: %s" % (encoding_parameters,), @@ -915,6 +916,7 @@ share_size = encoder.get_param("share_size") block_size = encoder.get_param("block_size") num_segments = encoder.get_param("num_segments") + precondition(isinstance(num_segments, (int, long)), num_segments) k,desired,n = encoder.get_param("share_counts") self._peer_selection_started = time.time() @@ -1270,6 +1272,8 @@ if self._all_encoding_parameters: return defer.succeed(self._all_encoding_parameters) + precondition(self.max_segment_size is None or isinstance(self.max_segment_size, (int, long)), self.max_segment_size) + precondition(isinstance(self.default_max_segment_size, (int, long)), self.default_max_segment_size) max_segsize = self.max_segment_size or self.default_max_segment_size k = self.encoding_param_k or self.default_encoding_param_k happy = self.encoding_param_happy or self.default_encoding_param_happy @@ -1277,10 +1281,13 @@ d = self.get_size() def _got_size(file_size): + precondition(isinstance(file_size, (int, long)), file_size) # for small files, shrink the segment size to avoid wasting space segsize = min(max_segsize, file_size) + precondition(isinstance(segsize, (int, long)), segsize) # this must be a multiple of 'required_shares'==k segsize = mathutil.next_multiple(segsize, k) + precondition(isinstance(segsize, (int, long)), segsize) encoding_parameters = (k, happy, n, segsize) self._all_encoding_parameters = encoding_parameters return encoding_parameters