This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 wraps a already bracketed print statement with another brackets
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, jimli, xtreak
Priority: normal Keywords:

Created on 2019-06-26 23:57 by jimli, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg346702 - (view) Author: Jim Li (jimli) Date: 2019-06-26 23:57
I encountered this issue when I was running 2to3 on a package, Python version 3.7.2, CentOS 7.

To reproduce this bug, create a file called test.py and paste the following code into it

def testSomeRequest(self):

    request = {"someRequest": "request"}
    response = self.sendSearchRequest(request)
    print(response.next_page_token)

The 2to3 tool would do the following:

-    print(response.next_page_token)
+    print((response.next_page_token))

Is this behaviour expected? Thank you.
msg346705 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-27 00:15
2to3 is designed to convert python2 code to python3. It is not designed to work on python3 code.

I believe this behavior is correct.
msg346706 - (view) Author: Jim Li (jimli) Date: 2019-06-27 00:19
Thanks Eric. That does make sense. The code wasn't really Python 3, it was migrated from 2.7, which uses some Python 3 syntax.

As a side note, if you run 2to3 on this instead of the previous `print(response.next_page_token)`

print(response)

Then 2to3 would say that nothing needs to be converted. It seems like the attribute plays a role here.

Thanks for the quick response. Feel free to close the issue.
msg346707 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-27 00:21
You might also want to look at python-modernize or similar tools.
msg346709 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-06-27 03:17
This is a duplicate of https://bugs.python.org/issue10375
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81604
2019-06-27 03:17:47xtreaksetnosy: + xtreak
messages: + msg346709
2019-06-27 00:21:16eric.smithsetstatus: open -> closed
type: behavior
messages: + msg346707

resolution: not a bug
stage: resolved
2019-06-27 00:19:23jimlisetmessages: + msg346706
2019-06-27 00:15:29eric.smithsetnosy: + eric.smith
messages: + msg346705
2019-06-26 23:57:50jimlicreate