[Twisted-Python] Could this be an error in pcp.py?

Jean-Paul Calderone exarkun at divmod.com
Wed Apr 23 10:29:57 EDT 2008


On Wed, 23 Apr 2008 15:31:08 +0200, Gabriel Rossetti <mailing_lists at evotex.ch> wrote:
>Hello,
>
>I was looking at pcp.py and I noticed this :
>
>    def resumeProducing(self):
>        self.paused = False
>        if self._buffer:
>            data = ''.join(self._buffer)
>            bytesSent = self._writeSomeData(data)
>            if bytesSent < len(data):
>                unsent = data[bytesSent:]
>                assert not self.iAmStreaming, (
>                    "Streaming producer did not write all its data.")
>                self._buffer[:] = [unsent]
>            else:
>                self._buffer[:] = []
>        else:
>            bytesSent = 0
>...
>
>
>in the ProducerConsumerProxy class, self._writeSomeData(data) returns the 
>length of what was written, but in the test right afterwards bytesSent is 
>compared to len(data), but they both have the same value, shouldn't it be 
>"if bytesSent < len(self._buffer):" instead?

`self._buffer´ is a list of strings (hence the join call to create `data´)
so comparing the number of bytes sent to its length wouldn't make sense.

Jean-Paul




More information about the Twisted-Python mailing list