[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-11-26 Thread Benjamin Peterson
Benjamin Peterson added the comment: I concur with Raymond. Thank you for the patch, but this seems too error-prone to commit. -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-11 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: I have added a final condition that converts the arguments passed to bytes only if the type of object is socket and the method is send() in the generated code. All the other conversions still function as expected. -- Added file:

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: Benjamin, I'm dubious about this going forward, but it is up to you. -- assignee: -> benjamin.peterson ___ Python tracker ___

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-07 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: I am sorry. I got you completely wrong with this > "One possibility is to add a type check to the generated code" I thought you were asking to check the type in the fixer itself. I get it now. So you meant to add the type check for the changed/generate

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-07 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: > One possibility is to add a type check to the generated code, "send(x)" -> > send(x.encode() if type(x)==bytes else x)" That would have solved the problem. However we cannot check the type of the object while the parsing is going on. For example,

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I have tweaked that fixer to handle the pointed cases > and a few additional ones too Playing whack-a-mole with a few cases will always fall short of being able to guarantee correct transformations and not break existing code that is working

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-06 Thread Pranav Devarakonda
Pranav Devarakonda 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

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm sure that this would break the code which sends bytes objects and expects to receive bytes objects. s.send(struct.pack('!I', x)) q, w, e = struct.unpack('!IHQ', s.recv(4)) -- ___ Python tracker

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Please find attached the fixer I wrote. Wouldn't this break programs that had already run encode() on the input (as they were already supposed to be doing, and as they would be doing for code that runs under both Python2 and Python3)? --

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-04 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: Thanks Karthikeyan -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-04 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Ah, sorry I totally forgot about dict fixer. Thanks for the details. I would wait for Benjamin's call on this. Thanks -- ___ Python tracker

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-04 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: Thanks for taking time and updating this, Karthikeyan Singaravelan. I do agree that there there is no proper way to find out if an object is of type socket or not. However other fixers in lib2to3 are not any different. For example the fix_dict.py

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-04 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the report. In my opinion it's difficult to handle this scenario and as far as I know 2to3 can only do syntax level changes with modular fixers for each case. Since Python is dynamic and there is no static type system available it's

[issue34893] Add 2to3 fixer to change send and recv methods of socket object.

2018-10-04 Thread Pranav Devarakonda
New submission from Pranav Devarakonda : 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