-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize Python 2 code to get ready for Python 3 #1335
Conversation
Any news on this PR? |
any interest by the maintainers to get this done? |
@refack Your review please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done, they should merge this
495 days until Python 2 end of life. https://bugs.chromium.org/p/gyp/issues/detail?id=36#c48 |
If anyone is interested in this PR then please submit a review:
The more approvals there are, the more confidence that Maintainers will have that these changes are worth making. |
I was waiting for the maintainer of upstream GYP to do something similar, but that probably won't happen. P.S. I have been working on reviving the GYP test suite from upstream. I feel it's important to have some regression testing so we'll be more confident this change is safe. |
What is the URL to the repo for "upstream GYP"? https://gyp.gsrc.io/ or other? |
https://gyp.gsrc.io/ |
@refack Can we please proceed with the review of this PR? Having this repo ready for the shift from legacy Python to Python will put more pressure on the maintainers of "upstream GYP" to get with the times. 450 days until Python 2 EOL. |
I guess the idea is that GN replaces GYP so we will never see major upstream GYP changes. I assume that Node needs to switch to something else entirely in the long run, but there are enough open issues for that, so we shouldn't get into this here... |
Is o-lim/generate-ninja#1 the canonical repo for GN? |
It is a fork. |
Does upstream score better on those tests than the fork does? |
Please, update README as well if it works with Python 3 |
Let’s not change README until we get more feedback from users. No syntax errors != fully ported. |
I had no errors for a while by now… with python2 |
please, run 2to3 again |
2to3 is a bad idea because it often breaks Python 2 compatibility to achieve Python 3 compatibility. This PR was created with futurize, not 2to3. |
I didn't said you need to apply it blindliy, but it's a good idea to highlight things. |
I'll review today. |
P.S. what I have been trying to do was revive the original GYP test suite as to have some gauge of the compatibility of this change. |
a few notes on 2to3:
try:
import urllib.parse as parse
except ImportError:
import urlparse as parse # name have to be the same (in most cases) try:
from io import StringIO
except ImportError:
from StringIO import StringIO |
Does gyp pass these two tests?
|
it's not recommended if your app is long living (not node-gyp) and lists contain millions of records. For compatible code for this particular project it's more convinient to use one function everywhere. |
#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
Happy futuring y'all |
Added another PR with more fixes. You're welcome to review, comment and add more changes there. |
nodejs/node-gyp#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
nodejs/node-gyp#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
nodejs/node-gyp#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
nodejs/node-gyp#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
nodejs/node-gyp#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
#1335 Reviewed-By: Refael Ackermann <refack@gmail.com>
Similar to #1150
Make the minimal, safe changes required to convert the repo's code to be syntax compatible with both Python 2 and Python 3. More work will be required to complete the port to Python 3 but this is a minimal, safe first step.
Checklist
npm install && npm test
passesDescription of change