Bug in SmartMedium._get_line()

John Arbash Meinel john at arbash-meinel.com
Mon May 21 12:04:13 BST 2007


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.
                 break
         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.

I may be missing a step, so I'm not reporting it as a bug yet 
(SM._get_bytes may be building up an internal buffer, or something else 
that I overlooked).

John
=:->



More information about the bazaar mailing list