Bug in SmartMedium._get_line()
robertc at robertcollins.net
Wed Jun 6 02:29:38 BST 2007
On Mon, 2007-05-21 at 13:04 +0200, John Arbash Meinel wrote:
> Hey, I thought I found a bug in SmartMedium._get_line()
> Specifically, it is doing:
> line = ''
> while not line or line[-1] != '\n':
> new_char = self._get_bytes(1)
> line += new_char
> if new_char == '':
> # Ran out of bytes before receiving a complete line.
> return line
> However, the SmartServerSocketStreamMedium._get_bytes is defined as:
> def _get_bytes(self, desired_count):
> # We ignore the desired_count because on sockets it's more
> efficient to
> # read 4k at a time.
> return self.socket.recv(4096)
> So I may be mis-reading what is calling what, but it sure looks like
> "_get_lines" is explicitly assuming no more than 1 character will be
> returned. And at a minimum it is only working when the socket returns
> exactly a single line.
No, You're misreading - + appends the entire returned bytestring. Its
saying that it needs 1 or more characters - dont bother returning with
less than 1 unless its EOF.
We can make this more clear, obviously.
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070606/d3d920b2/attachment.pgp
More information about the bazaar