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

Return the error codes instead of implicitly returning None #13344

Closed
wafflespeanut opened this issue Sep 21, 2016 · 11 comments
Closed

Return the error codes instead of implicitly returning None #13344

wafflespeanut opened this issue Sep 21, 2016 · 11 comments

Comments

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Sep 21, 2016

Some of the methods in testing_commands.py have a returning pattern like,

result = call(...)
if result != 0:
    return result

Instead of doing that check and implicitly returning None, we could just return the result, since 0 and None have the same boolean evaluation in python.

Code: python/servo/testing_commands.py

@highfive
Copy link

@highfive highfive commented Sep 21, 2016

Please make a comment here if you intend to work on this issue. Thank you!

@wafflespeanut
Copy link
Member Author

@wafflespeanut wafflespeanut commented Sep 21, 2016

Great!

@uber1geek
Copy link

@uber1geek uber1geek commented Sep 21, 2016

I wanted to work on this issue as well :)

@wafflespeanut
Copy link
Member Author

@wafflespeanut wafflespeanut commented Sep 21, 2016

Sorry, @bubbles231 claimed this first. Feel free to poke other unclaimed easy issues, or comment here (or ping us at the #servo channel in the IRC) if you want help :)

@wafflespeanut
Copy link
Member Author

@wafflespeanut wafflespeanut commented Sep 21, 2016

I meant that they both have similar boolean evaluation (i.e) how the __nonzero__ magic method is implemented. In other words,

if None: print 'Hello'
# doesn't print anything
if 0: print 'Hello'
# doesn't print anything

Hence, there's no great reason to prefer None instead of 0 :)

@bubbles231
Copy link
Contributor

@bubbles231 bubbles231 commented Sep 21, 2016

un assign me please

@wafflespeanut
Copy link
Member Author

@wafflespeanut wafflespeanut commented Sep 21, 2016

@bubbles231 Thanks for letting us know!

@uber1geek It's yours then! :)

@uber1geek
Copy link

@uber1geek uber1geek commented Sep 21, 2016

@wafflespeanut Return result seems good, I was thinking if we just make it an empty value. it will evaluate to false and that solves the issue imo.

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Sep 21, 2016

I'm not sure what you're trying to get at here. This is what I think is being proposed:

return call(...)
@wafflespeanut
Copy link
Member Author

@wafflespeanut wafflespeanut commented Sep 28, 2016

@uber1geek Any updates on this?

@nivekuil
Copy link
Contributor

@nivekuil nivekuil commented Sep 29, 2016

I'd like to claim this. Sent a PR.

@jdm jdm added the C-assigned label Sep 29, 2016
bors-servo added a commit that referenced this issue Oct 1, 2016
Return the error codes instead of implicitly returning None

See #13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13513)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Oct 1, 2016
Return the error codes instead of implicitly returning None

See #13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13513)
<!-- Reviewable:end -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 4, 2017
…turning None (from nivekuil:master); r=Wafflespeanut

See servo/servo#13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0e950c0ba5ba96ab629a21e8bdeba0795e320316
xeonchen pushed a commit to xeonchen/gecko-cinnabar that referenced this issue Feb 4, 2017
…turning None (from nivekuil:master); r=Wafflespeanut

See servo/servo#13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0e950c0ba5ba96ab629a21e8bdeba0795e320316
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 1, 2019
…turning None (from nivekuil:master); r=Wafflespeanut

See servo/servo#13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0e950c0ba5ba96ab629a21e8bdeba0795e320316

UltraBlame original commit: c2e967be59e9324e8b7c9e34f67233f5fb83386d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 1, 2019
…turning None (from nivekuil:master); r=Wafflespeanut

See servo/servo#13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0e950c0ba5ba96ab629a21e8bdeba0795e320316

UltraBlame original commit: c2e967be59e9324e8b7c9e34f67233f5fb83386d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 1, 2019
…turning None (from nivekuil:master); r=Wafflespeanut

See servo/servo#13344

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #13344 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring without logic changes, 0 is falsey as None

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0e950c0ba5ba96ab629a21e8bdeba0795e320316

UltraBlame original commit: c2e967be59e9324e8b7c9e34f67233f5fb83386d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

7 participants
You can’t perform that action at this time.