-
Notifications
You must be signed in to change notification settings - Fork 30k
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: make EnvDelete behave like the delete operator #7975
Conversation
This changes observable behavior of |
#ifdef __POSIX__ | ||
node::Utf8Value key(info.GetIsolate(), property); | ||
rc = getenv(*key) != nullptr; | ||
if (rc) | ||
bool has_key = getenv(*key) != nullptr; |
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 could fold this into the if statement.
Can you reword the commit log so it says "src: make EnvDelete etc etc"? As to whether this should be semver-major or not, I personally lean towards bug fix. |
#ifdef __POSIX__ | ||
node::Utf8Value key(info.GetIsolate(), property); | ||
rc = getenv(*key) != nullptr; | ||
if (rc) | ||
if (getenv(*key) != nullptr) |
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.
Is this check even necessary anymore?
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.
Good catch, according to unsetenv(3) no need for it. I'm assuming unsetenv()
is not slower than doing the getenv()
check first.
Got a question but otherwise this is looking good! |
According to TC39 specification, the delete operator returns false or throws in strict mode, if the property is non-configurable. It returns true in all other cases. Process.env can never have non-configurable properties, thus EnvDelete must always return true. This is independent of strict mode. Fixes nodejs#7960
Thanks! CI: https://ci.nodejs.org/job/node-test-commit/4398/ |
LGTM |
2 similar comments
LGTM |
LGTM |
@addaleax ... does this LGTY? |
Yes, LGTM! :) |
Awesome, thank you! will get this landed now. |
According to TC39 specification, the delete operator returns false or throws in strict mode, if the property is non-configurable. It returns true in all other cases. Process.env can never have non-configurable properties, thus EnvDelete must always return true. This is independent of strict mode. Fixes: #7960 PR-URL: #7975 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Landed in ff7a841! thank you @fhinkel! |
According to TC39 specification, the delete operator returns false or throws in strict mode, if the property is non-configurable. It returns true in all other cases. Process.env can never have non-configurable properties, thus EnvDelete must always return true. This is independent of strict mode. Fixes: #7960 PR-URL: #7975 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
adding lts watch label. please let me know if this should be landed or not |
Not sure. My feeling is we don't need this fix in v4. |
moving to don't land thanks @fhinkel |
Checklist
make -j4 test
(UNIX) passesdelete
in the exampleAffected core subsystem(s)
src
Description of change
According to TC39 specification, the delete
operator returns false or throws
in strict mode, if the property is
non-configurable. It returns true in all other cases.
Process.env can never have non-configurable
properties, thus EnvDelete must always return true. This
is independent of strict mode.
Fixes #7960