[New-bugs-announce] [issue36047] socket file handle does not support stream write

wang xuancong report at bugs.python.org
Tue Feb 19 21:32:25 EST 2019


New submission from wang xuancong <xuancong84 at gmail.com>:

Python3 programmers have forgotten to convert/implement the socket file descriptor for IO stream operation. Would you please add it? Thanks!

import socket
s = socket.socket()
s.connect('localhost', 5432)
S = s.makefile()

# on Python2, the following works
print >>S, 'hello world'
S.flush()

# on Python3, the same thing does not work
print('hello world', file=S, flush=True)

It gives the following error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: not writable

Luckily, the stream read operation works, S.readline()

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 336035
nosy: xuancong84
priority: normal
severity: normal
status: open
title: socket file handle does not support stream write
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36047>
_______________________________________


More information about the New-bugs-announce mailing list