Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

thefourtheye
Copy link
Contributor

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/

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.
@thefourtheye thefourtheye added the test Issues and PRs related to the tests. label Aug 26, 2015
@rmg
Copy link
Contributor

rmg commented Aug 27, 2015

LGTM 👍

if additional is not None:
self.additional_flags = additional
else:
self.additional_flags = []
Copy link
Member

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 [].

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis ping!

@bnoordhuis
Copy link
Member

LGTM with a suggestion.

@bnoordhuis
Copy link
Member

Just to confirm: LGTM. A suggestion means you're free to take it or leave it. :-)

thefourtheye added a commit that referenced this pull request Sep 15, 2015
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 <info@bnoordhuis.nl>
@thefourtheye
Copy link
Contributor Author

Thanks for the review Ben, landed in 52f84ad. I had changed, the super call of AddonTestConfiguration by passing additional to it.

@thefourtheye thefourtheye deleted the test_py_fix branch September 15, 2015 14:36
thefourtheye added a commit that referenced this pull request Sep 15, 2015
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 <info@bnoordhuis.nl>
@Fishrock123 Fishrock123 mentioned this pull request Sep 15, 2015
7 tasks
@rvagg rvagg mentioned this pull request Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants