classification
Title: socket line buffering
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, jbrouwers (2)
Priority: normal Keywords

Created on 2004-01-18 19:37 by jbrouwers, last changed 2009-02-14 11:34 by ajaksu2.

Messages (2)
msg60460 - (view) Author: Jean M. Brouwers (jbrouwers) Date: 2004-01-18 19:37
There is a bug in the line buffering code in the
Lib/socket.py module.

The write() method in the _fileobject class will flush
the buffered data at every call even if there no new
line character present in the data.

The problem is that the third part of the last if
statement will always be True if self._wbufsize equals 1.

<pre>
  if (self._wbufsize == 0 or
      self._wbufsize == 1 and '\n' in data or
      self._get_wbuf_len() >= self._wbufsize):
      self.flush()
</pre>

A possible fix would be the following:

<pre>
  if (self._wbufsize == 0 or
      self._wbufsize == 1 and '\n' in data or
      self._wbufsize > 1 and self._get_wbuf_len() >=
self._wbufsize):
      self.flush()
</pre>
msg82012 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-14 11:34
The code described by Jean is still present.
History
Date User Action Args
2009-02-14 11:34:54ajaksu2settype: behavior
stage: test needed
messages: + msg82012
nosy: + ajaksu2
versions: + Python 2.6, - Python 2.3
2004-01-18 19:37:59jbrouwerscreate