-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: allow getting Symbols on process.env #9631
Conversation
1aa595e introduced a `throw` for accessing `Symbol` properties of `process.env`. However, this breaks `util.inspect(process)` and things like `Object.prototype.toString.call(process.env)`, so this patch changes the behaviour for the getter to just always return `undefined`.
@@ -2681,6 +2681,9 @@ static void ProcessTitleSetter(Local<Name> property, | |||
static void EnvGetter(Local<Name> property, | |||
const PropertyCallbackInfo<Value>& info) { | |||
Isolate* isolate = info.GetIsolate(); | |||
if (property->IsSymbol()) { | |||
return info.GetReturnValue().SetUndefined(); |
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.
Calling .SetUndefined()
explicitly doesn't hurt but it's not strictly necessary as it's the default return value. We don't call it anywhere else.
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.
@bnoordhuis I think making the return value explicit is more readable here, that’s all. If you prefer, I have no problem dropping it.
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.
It's fine.
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.
Isn't this the C++ equivalent of function() { return undefined; }
? I've no strong feelings, but explicit isn't necessarily more readable, IMHO.
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.
Isn't this the C++ equivalent of
function() { return undefined; }
?
Yup.
I've no strong feelings, but explicit isn't necessarily more readable, IMHO.
I agree, but in this instance I think it makes sense.
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.
LGTM
Marking as semver-major due to the change in error handling. |
@jasnell This partially undoes a not-yet-released |
Landed in 3295a7f, thanks for reviewing everyone! |
1aa595e introduced a `throw` for accessing `Symbol` properties of `process.env`. However, this breaks `util.inspect(process)` and things like `Object.prototype.toString.call(process.env)`, so this patch changes the behaviour for the getter to just always return `undefined`. Ref: #9446 Fixes: #9641 PR-URL: #9631 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
It's a bit of a grey area On Sat, Nov 19, 2016 at 4:05 PM Anna Henningsen notifications@github.com
|
1aa595e introduced a `throw` for accessing `Symbol` properties of `process.env`. However, this breaks `util.inspect(process)` and things like `Object.prototype.toString.call(process.env)`, so this patch changes the behaviour for the getter to just always return `undefined`. Ref: nodejs#9446 Fixes: nodejs#9641 PR-URL: nodejs#9631 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
process
Description of change
1aa595e introduced a
throw
for accessingSymbol
properties ofprocess.env
. However, this breaksutil.inspect(process)
and things likeObject.prototype.toString.call(process.env)
, so this patch changes the behaviour for the getter to just always returnundefined
./cc @cjihrig