classification
Title: Double parenthesis in print function running 2to3 in already correct call
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, jondaa, xtreak
Priority: normal Keywords:

Created on 2018-12-05 10:10 by jondaa, last changed 2018-12-05 12:33 by xtreak.

Messages (2)
msg331098 - (view) Author: Jonathan Alush-Aben (jondaa) Date: 2018-12-05 10:10
If 2to3 is run on a file with the following contents:
a="string"
print ("%s" % a)

The output is:

a="string"
print (("%s" % a))

Although it was already a valid call to print in python3.
msg331104 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2018-12-05 12:33
Thanks for the report. Is this similar to issue10375 ? One option would be to use -p to stop transforming print related code if you don't want to transform any print statement.


$ cat /tmp/foo.py
print (1)

$ 2to3 /tmp/foo.py
[snip]
--- /tmp/foo.py	(original)
+++ /tmp/foo.py	(refactored)
@@ -1 +1 @@
-print (1)
+print((1))

$ 2to3 -p /tmp/foo.py
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: No files need to be modified.
History
Date User Action Args
2018-12-05 12:33:08xtreaksetnosy: + benjamin.peterson, xtreak
messages: + msg331104
2018-12-05 10:10:19jondaacreate