Pranav Devarakonda <devarakondapra...@yahoo.com> added the comment:

Thanks for pointing out these cases. I kept in mind the Python 2 documentation 
which says socket.send method expects a string and hence made that fixer. I 
have tweaked that fixer to handle the pointed cases and a few additional ones 
too. Please find attached the updated fixer. To summarize, the following send() 
cases would not be changed,

data = "Data"
s.send(str.encode(data))
s.send(data.encode('utf-8))
s.send(bytes(data, 'utf-8'))
s.send(struct.pack('!I', x))

Similary, the following recv() cases would not be changed, 

data = s.recv(1024).decode('utf-8')
q, w, e = struct.unpack('!IHQ', s.recv(4))

The remaining generic cases will be handled as expected. I know we cannot 
handle cases where the data has already been converted to bytes(since there is 
no way to find the 'type' of the object here) and then sent as an argument to 
socket.send(). But if we have to go by the documentation, then this is probably 
the right thing to do.

----------
Added file: https://bugs.python.org/file47854/fix_socket_send_recv_updated.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34893>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to