-
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 #1571
Conversation
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.
Great stuff... Just two minor change requests. Thanks.
gyp/pylib/gyp/simple_copy.py
Outdated
for x in (type(None), int, long, float, | ||
bool, str, unicode, type): | ||
import sys | ||
if sys.version_info < (3, 0): |
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.
On this one, can we please follow Python porting best practice use feature detection instead of version detection?
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.
extracted checks to compat
module
gyp/pylib/gyp/xcodeproj_file.py
Outdated
@@ -155,6 +155,9 @@ | |||
_new_sha1 = sha.new | |||
|
|||
|
|||
if sys.version_info >= (3, 0): # just easier | |||
unicode = str |
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.
On this one, can we please follow Python porting best practice use feature detection instead of version detection?
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.
There's a reason for it in this case: exception -> substitution will run much slower than knowlege of version where this name doesn't exist. This is also used in six
and works well.
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.
so I'd prefer to leave this kind of check for types and for a dictionary. But I can change if you'd insist on it.
@refack it won't work as I found a lot more issues in code to be ported |
This doesn't mean, his work is useless. |
@refack @cclauss Could you have a chance to know what these variables should be? I haven't found any traces of them in functions they are and how to fix these lines.
|
As long as it passes CI, I take it as a sign it doesn't regress. I assumed that work was not done yet to get actual py3 compat. |
My PR also passes CI, but not finished :D There's many things to fix Before you try to merge it, I'd like to finish some other checks. I'll let you know |
Merged and I've done for today. Unresolved questions for the next run are:
|
@refack I finished, including merging |
@cclauss for this run I used |
@eirnym I've rebased you branch. Before you continue, take a tag, and pull with |
you lost at least a half of my changes during rebasing. Merge would be always easier. |
We keep a linier git history, so we rebase. Some changes were incompatible with #1572 so I did not base them. |
If you'd tell me before, It would be just easier to rebase them manually. Now I repeat my work. |
Sorry. I'm juggling several branches, and reviewing a ton of code... |
I understand, but tell about this to a developer to save their time. It's already half past midnight and I'm restoring changes for an hour by now instead going to sleep. |
Sorry again. Thank you for the dedication. |
Next possible day will be in a few days and I don't want to forget and start all things over again. |
I restored changes. Commit is a bit bulky, but it does it's job right. |
Thank you very much 🥇 |
So what the current state of the PR? |
Conflicts. I have approved but I am not a maintainer. Overall, I would feel more comfortable if we used the six module (or futurize) instead of inventing our own from scratch. The linter directives in gyp/pylib/gyp/compat.py are just as a result of a refusal to follow Python porting best practice use feature detection instead of version detection. The map()s and filter()s would be faster and more readable as list comprehensions. |
@cclauss I feel the same about Checking Python version is significantly faster and stable enough and it's used even in about |
And please, remember that we have no tests. |
One more thing about compatibility and Python version checking: this is only about syntax and builtins checking. For Python2 you can't use |
@refack almost 2 weeks passed since I done this work. Please, tell me what else needs to be done here? |
Conflicts :-( |
@cclauss it's easy to solve code conflicts, but I don't see any intention from maintainers to merge these changes anyway. |
I gave up on this branch. I have a copy if anybody would be intereseted in merging it. |
C
Checklist
npm install && npm test
passesDescription of change
Continuation of #1335 and #1150. Please, review, comment, add more changes and fixes :) All changes are splitted, as some of them are massive.
UPDATE 1
Now I'm fighting with
test/test-find-python.js
file to allow it even to start testing in Python3-only environment.UPDATE 2
Tests are passing, but it's possible that I'd miss something