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 devarakondapranav
Recipients benjamin.peterson, devarakondapranav, rhettinger, serhiy.storchaka, xtreak
Date 2018-10-06.18:15:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538849716.2.0.545547206417.issue34893@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-10-06 18:15:16devarakondapranavsetrecipients: + devarakondapranav, rhettinger, benjamin.peterson, serhiy.storchaka, xtreak
2018-10-06 18:15:16devarakondapranavsetmessageid: <1538849716.2.0.545547206417.issue34893@psf.upfronthosting.co.za>
2018-10-06 18:15:16devarakondapranavlinkissue34893 messages
2018-10-06 18:15:16devarakondapranavcreate