Uh oh!
There was an error while loading. Please reload this page.
Modernize Python 2 code to get ready for Python 3 - #1571
Conversation
cclauss
left a comment
There was a problem hiding this comment.
Great stuff... Just two minor change requests. Thanks.
| 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.
On this one, can we please follow Python porting best practice use feature detection instead of version detection?
| if sys.version_info >= (3, 0): # just easier | ||
| unicode = str |
There was a problem hiding this comment.
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.
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.
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
commented
Oct 14, 2018
eirnym
commented
Oct 14, 2018
@refack it won't work as I found a lot more issues in code to be ported |
eirnym
commented
Oct 14, 2018
This doesn't mean, his work is useless. |
eirnym
commented
Oct 14, 2018
@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. |
cclauss
commented
Oct 14, 2018
refack
commented
Oct 14, 2018
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. |
eirnym
commented
Oct 14, 2018
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 |
eirnym
commented
Oct 14, 2018
Merged and I've done for today. Unresolved questions for the next run are:
|
eirnym
commented
Oct 14, 2018
@refack I finished, including merging |
eirnym
commented
Oct 14, 2018
@cclauss for this run I used |
refack
commented
Oct 14, 2018
@eirnym I've rebased you branch. Before you continue, take a tag, and pull with |
eirnym
commented
Oct 14, 2018
you lost at least a half of my changes during rebasing. Merge would be always easier. |
refack
commented
Oct 14, 2018
We keep a linier git history, so we rebase. Some changes were incompatible with #1572 so I did not base them. |
eirnym
commented
Oct 14, 2018
If you'd tell me before, It would be just easier to rebase them manually. Now I repeat my work. |
refack
commented
Oct 14, 2018
Sorry. I'm juggling several branches, and reviewing a ton of code... |
eirnym
commented
Oct 14, 2018
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. |
refack
commented
Oct 14, 2018
Sorry again. Thank you for the dedication. |
eirnym
commented
Oct 14, 2018
Next possible day will be in a few days and I don't want to forget and start all things over again. |
eirnym
commented
Oct 14, 2018
I restored changes. Commit is a bit bulky, but it does it's job right. |
refack
commented
Oct 14, 2018
Thank you very much 🥇 |
eirnym
commented
Oct 18, 2018
So what the current state of the PR? |
eirnym
commented
Oct 20, 2018
cclauss
commented
Oct 21, 2018
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 |
eirnym
commented
Oct 21, 2018
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 |
eirnym
commented
Oct 25, 2018
@refack almost 2 weeks passed since I done this work. Please, tell me what else needs to be done here? |
cclauss
commented
Nov 15, 2018
Conflicts :-( |
eirnym
commented
Nov 18, 2018
@cclauss it's easy to solve code conflicts, but I don't see any intention from maintainers to merge these changes anyway. |
eirnym
commented
Nov 18, 2018
I gave up on this branch. I have a copy if anybody would be intereseted in merging it. |
C
Checklist
npm install && npm testpassesDescription 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.jsfile 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