Issue 879399: socket line buffering (original) (raw)

Created on 2004-01-18 19:37 by jbrouwers, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
_fileobject.diff kristjan.jonsson,2012-12-14 11:29
_fileobject.diff kristjan.jonsson,2012-12-20 13:41
_fileobject23122012.diff 0lejka,2012-12-23 12:50 review
Messages (11)
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.
   if (self._wbufsize == 0 or       self._wbufsize == 1 and '\n' in data or       self._get_wbuf_len() >= self._wbufsize):       self.flush() 
A possible fix would be the following:
   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() 
msg82012 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-14 11:34
The code described by Jean is still present.
msg114312 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-19 00:35
I'm just wondering if the original code could be the cause of subtle bugs with socket.py, anyone? (I'm no sockets guru). There's a proposed inline patch that's never been implemented, what do you (plural) make of it?.
msg177458 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-12-14 11:29
Here's a patch for the current 2.7 stuff, from issue #16680 (which was deemed duplicate). Unless anyone objects, I'll commit that to 2.7 soon. Eight years, this has taken.
msg177464 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-14 16:34
Would be nice to add a test...
msg177471 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-12-14 17:09
Good point, will do.
msg177816 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-12-20 13:41
New patch, with unittest.
msg177982 - (view) Author: oleg chubin (0lejka) * Date: 2012-12-23 12:50
I just have updated patch for current version of code. It looks good for me.
msg177986 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-23 13:47
LGTM. Kristján, would you like to commit?
msg178020 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-12-23 23:01
Sure, Leave it to me.
msg178123 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-25 13:06
New changeset 5be3fa83d436 by Kristján Valur Jónsson in branch '2.7': issue #879399 http://hg.python.org/cpython/rev/5be3fa83d436
History
Date User Action Args
2022-04-11 14:56:02 admin set github: 39835
2012-12-25 13:34:19 asvetlov set status: open -> closedstage: patch review -> resolved
2012-12-25 13:08:05 kristjan.jonsson set resolution: fixed
2012-12-25 13:06:55 python-dev set nosy: + python-devmessages: +
2012-12-24 10:16:05 asvetlov set assignee: kristjan.jonsson
2012-12-23 23:01:36 kristjan.jonsson set messages: +
2012-12-23 13:47:52 asvetlov set messages: +
2012-12-23 12:50:02 0lejka set files: + _fileobject23122012.diffnosy: + asvetlov, 0lejkamessages: +
2012-12-20 13:41:41 kristjan.jonsson set files: + _fileobject.diffmessages: +
2012-12-14 17:09:53 kristjan.jonsson set messages: +
2012-12-14 16:34:12 pitrou set nosy: + pitroumessages: + versions: - Python 3.1, Python 3.2
2012-12-14 11:29:25 kristjan.jonsson set files: + _fileobject.diffnosy: + kristjan.jonssonmessages: + keywords: + patch
2012-12-14 10:07:33 neologix link issue16680 superseder
2010-08-19 00:35:56 BreamoreBoy set versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6nosy: + BreamoreBoymessages: + stage: test needed -> patch review
2009-02-14 11:34:54 ajaksu2 set type: behaviorstage: test neededmessages: + nosy: + ajaksu2versions: + Python 2.6, - Python 2.3
2004-01-18 19:37:59 jbrouwers create