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

2018-11-26 Thread Benjamin Peterson
Benjamin Peterson added the comment: I'm disinclined to change the fix here after it's existed in this for for 10 years. -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker

[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 parenthesis to the

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

2018-10-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the patch but I feel adding type checks will add more complexity to the code being converted and there are a lot of cases to handle. I have some code below where running 2to3 will just wrap the keys() call to a list but with the patch

[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