-
Notifications
You must be signed in to change notification settings - Fork 29.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
gyp: cherrypick python3 changes to input.py from node-gyp #29140
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.
rubber-stamp
b3e2b29
to
b601fe0
Compare
I doubt this will pass ci's linter check on the commit messages, the 2 last commits should be squashed into the first --- I'd do it, but @cclauss your branch is protected, you'll have to unprotect it, or do the squashing yourself, or perhaps it can be done on landing if ci is green, I'm not sure if we do that. |
b601fe0
to
83df0d2
Compare
83df0d2
to
227fbee
Compare
227fbee
to
4c7eae1
Compare
4c7eae1
to
f6885f4
Compare
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.
Rubber-stamp LGTM
What's the best way to land this? Squash everything into a single commit? |
+1 to squash the commit. |
I usually squash like this combined with a well timed git rebase -i master. However that creates merge commits and requires force push which does not work for this community. Can someone point me to the handful of commands that would allow me to squash without causing rework? A pointer here or I am @cclauss on Slack. |
@cclauss |
tools/gyp/pylib/gyp/input.py
Outdated
@@ -709,6 +698,9 @@ def FixupPlatformCommand(cmd): | |||
|
|||
def ExpandVariables(input, phase, variables, build_file): | |||
# Look for the pattern that gets expanded into variables | |||
def to_utf8(s): | |||
return s if isinstance(s, str) else s.decode("utf-8") |
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.
Style nit: single quotes.
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.
The Python Software Foundation is going in the opposite direction so the muscle memory is building up but will fix.
raise GypError("%s while executing command '%s' in %s" % | ||
(e, contents, build_file)) | ||
|
||
p_stdout, p_stderr = p.communicate('') | ||
p_stdout = to_utf8(p_stdout) | ||
p_stderr = to_utf8(p_stderr) |
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.
I suppose this might cause a runtime exception when the output contains e.g. latin1-encoded file paths?
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.
You are correct. There is the old adage that you can never accurately guess encodings -- you have to be told. Should we leave as is or how should we resolve? We could catch the UnicodeDecodeError and then attempt to return s.decode('latin-1') and if we catch another UnicodeDecodeError just return s. Other approaches?
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.
That sounds reasonable, that probably covers 99% of everyday use.
f6885f4
to
bbde699
Compare
Landed in 3b92998 |
PR-URL: #29140 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: #29140 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: nodejs#29140 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> (cherry picked from commit 3b92998)
Built on the lessons learned in #29130 if we bring all changes done to this file in node-gyp, that breaks our Travis CI tests so this PR cherrypicks only the Python 3 compatibility changes. These changes are somewhat complex because the complier module was removed in Python 3 in favor of ast which was introduced in Python 2.5.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes