diff --git a/amodem/common.py b/amodem/common.py index d260016..cf9e078 100644 --- a/amodem/common.py +++ b/amodem/common.py @@ -83,7 +83,7 @@ class Splitter(object): while True: if all(self.read): try: - self.last = self.iterable.next() + self.last = next(self.iterable) except StopIteration: return diff --git a/amodem/recv.py b/amodem/recv.py index 2a7d116..d47fcba 100755 --- a/amodem/recv.py +++ b/amodem/recv.py @@ -193,7 +193,7 @@ def demodulate(symbols, filters, freqs, sampler): stats['rx_start'] = time.time() log.info('Demodulation started') - for i, block in enumerate(itertools.izip(*streams)): # block per frequency + for i, block in enumerate(common.izip(*streams)): # block per frequency for bits in block: stats['rx_bits'] = stats['rx_bits'] + len(bits) yield bits diff --git a/amodem/sampling.py b/amodem/sampling.py index 56a68d3..e55221d 100755 --- a/amodem/sampling.py +++ b/amodem/sampling.py @@ -49,6 +49,8 @@ class Sampler(object): def next(self): return self._sample() * self.gain + __next__ = next + def _sample(self): offset = self.offset # offset = k + (j / self.resolution) @@ -58,7 +60,7 @@ class Sampler(object): end = k + self.width while self.index < end: self.buff[:-1] = self.buff[1:] - self.buff[-1] = self.src.next() # throws StopIteration + self.buff[-1] = next(self.src) # throws StopIteration self.index += 1 self.offset += self.freq diff --git a/amodem/wave.py b/amodem/wave.py index 7ab4a98..269c66f 100755 --- a/amodem/wave.py +++ b/amodem/wave.py @@ -27,7 +27,7 @@ def record(fname, **kwargs): def launch(*args, **kwargs): - args = map(str, args) + args = list(map(str, args)) log.debug('$ %s', ' '.join(args)) p = sp.Popen(args=args, **kwargs) p.stop = lambda: os.kill(p.pid, signal.SIGKILL) diff --git a/tests/test_common.py b/tests/test_common.py index c5e32aa..7858fec 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -25,13 +25,13 @@ def test_iterate(): def test_split(): L = [(i*2, i*2+1) for i in range(10)] iters = common.split(L, n=2) - assert zip(*iters) == L + assert list(zip(*iters)) == L for i in [0, 1]: iters = common.split(L, n=2) - iters[i].next() + next(iters[i]) try: - iters[i].next() + next(iters[i]) assert False except IndexError as e: assert e.args == (i,) @@ -43,8 +43,8 @@ def test_icapture(): z = [] for i in common.icapture(x, result=y): z.append(i) - assert x == y - assert x == z + assert list(x) == y + assert list(x) == z def test_dumps_loads(): diff --git a/tests/test_stream.py b/tests/test_stream.py index d4e3a07..e220e26 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -19,7 +19,7 @@ def test_read(): p.stdin.close() f = stream.Reader(p.stdout) - result = zip(range(10), f) + result = list(zip(range(10), f)) p.kill() j = 0