-
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
test: fix default value for additional param #2553
Conversation
In Python, the default values of parameters are evaluated only once during their declaration. So, whenever the default parameter is used the same object will be used. Since we use a list, which is a mutable object, this could lead to unexpected results.
LGTM 👍 |
if additional is not None: | ||
self.additional_flags = additional | ||
else: | ||
self.additional_flags = [] |
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 shorten this to self.additional_flags = additional or []
.
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 Correct but if an empty list is actually passed, we ll still ignore it and create a new list, if we do additional or []
. We don't want that.
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 ping!
LGTM with a suggestion. |
Just to confirm: LGTM. A suggestion means you're free to take it or leave it. :-) |
In Python, the default values of parameters are evaluated only once during their declaration. So, whenever the default parameter is used the same object will be used. Since we use a list, which is a mutable object, this could lead to unexpected results. PR-URL: #2553 Reviewed-By: Ben Noordhuis <[email protected]>
Thanks for the review Ben, landed in 52f84ad. I had changed, the super call of |
In Python, the default values of parameters are evaluated only once during their declaration. So, whenever the default parameter is used the same object will be used. Since we use a list, which is a mutable object, this could lead to unexpected results. PR-URL: #2553 Reviewed-By: Ben Noordhuis <[email protected]>
In Python, the default values of parameters are evaluated only once
during their declaration. So, whenever the default parameter is used
the same object will be used. Since we use a list, which is a mutable
object, this could lead to unexpected results.
cc @nodejs/build
CI Run: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/169/