[issue34978] check type of object in fix_dict.py in 2to3

2018-10-15 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: Thank you very much for pointing out some helpful things, Karthikeyan. >True if 1 in list(a.keys()) if type(a) == dict else a.keys() else False True that the fixer would return a syntax error in this case. I missed adding a pair of parenthe

[issue34978] check type of object in fix_dict.py in 2to3

2018-10-13 Thread Pranav Devarakonda
New submission from Pranav Devarakonda : fix_dict.py applies fixes to every instance of keys(), items() or values() irrespective of the type of object. Since 2to3 cannot check the type of the object, we can at least add the check to the generated code like... d.keys() -> list(d.keys) if t

[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: https

[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 cha

[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

[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-04 Thread Pranav Devarakonda
Pranav Devarakonda added the comment: Thanks Karthikeyan -- ___ Python tracker <https://bugs.python.org/issue34893> ___ ___ Python-bugs-list mailing list Unsub

[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 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