Stéphane Wirtel added the comment:
I confirm that you don't use socket.makefile in write mode.
Python 3.7.2 (default, Jan 16 2019, 19:49:22)
[GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> s =
Windson Yang added the comment:
>From the docs
>https://docs.python.org/3/library/socket.html#socket.socket.makefile, the
>default mode for makefile() is 'r' (only readable). In your example, just use
>S = s.makefile(mode='w') instead.
--
nosy: +Windson Yang
New submission from wang xuancong :
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