This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kaizhu
Recipients eric.smith, kaizhu, pitrou
Date 2010-10-08.03:24:45
SpamBayes Score 1.4731549e-12
Marked as misclassified No
Message-id <1286508287.93.0.0400254171427.issue10041@psf.upfronthosting.co.za>
In-reply-to
Content
my bad for not rtfm, but it seems the newline argument has no effect in socket.makefile.

the TextIOWrapper signatures don't seem to match.  a hack to put newline parameter in 4th position or making it a keyword arg doesn't work either (scratch my head...)

socket.py source <line 162>
        text = io.TextIOWrapper(buffer, encoding, newline)

textio.c <line 807>
static int
textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
{
    char *kwlist[] = {"buffer", "encoding", "errors",
                      "newline", "line_buffering",
                      NULL};




$ python3 echo.py ## from previous example

$ python3 client.py 
b'hello\r\n' recv()
b'hello\r\n' makefile(mode = "rb")
'hello\n' makefile(mode = "r", newline = "")



# echo client program
data = b'hello\r\n'
import socket
clie = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
  clie.connect(('localhost', 12345))

  clie.send(data)
  data = clie.recv(4096)
  print(repr(data), 'recv()')

  clie.send(data)
  file = clie.makefile('rb')
  data = file.readline()
  print(repr(data), 'makefile(mode = "rb")')

  clie.send(data)
  file = clie.makefile('r', newline = '')
  data = file.readline()
  print(repr(data), 'makefile(mode = "r", newline = "")') ## '\r' is still silently dropped
finally:
  clie.close()
History
Date User Action Args
2010-10-08 03:24:48kaizhusetrecipients: + kaizhu, pitrou, eric.smith
2010-10-08 03:24:47kaizhusetmessageid: <1286508287.93.0.0400254171427.issue10041@psf.upfronthosting.co.za>
2010-10-08 03:24:46kaizhulinkissue10041 messages
2010-10-08 03:24:45kaizhucreate