New submission from Pranav Devarakonda <[email protected]>:
The send() method of the the Socket object in Python 3.x requires the data to
be sent to be first converted into bytes(object) which was not the case with
Python 2.x. The 2to3 tool doesn't handle this case and hence an explicit fixer
would help many beginners learning the socket module(most tutorials regarding
this online are in Python 2.x)
Similarly the fixer can change the recv() method by converting the returned
bytes object back to a str object.
For example, consider the following lines in Python 2.x, (for demonstration
only)
s.send("Foo") #where 's' is a socket object
data = s.recv(1024)
After the 2to3 fixer has been applied the above lines will change to,
s.send(str.encode("Foo"))
data = s.recv(1024).decode("utf-8")
PS: I am a beginner in open source so any changes or suggestions are welcome.
----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 327053
nosy: benjamin.peterson, devarakondapranav
priority: normal
severity: normal
status: open
title: Add 2to3 fixer to change send and recv methods of socket object.
type: enhancement
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34893>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com