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

tests: Handle ImportError explicitly, improve comparisons against None #14903

Merged
merged 4 commits into from
Dec 13, 2018

Conversation

daniel-s-ingram
Copy link
Contributor

No description provided.

@jonasschnelli
Copy link
Contributor

meh ACK

@practicalswift
Copy link
Contributor

practicalswift commented Dec 10, 2018

ACK 1b89074

I think we should use is None/is not None instead of == None/!= None throughout the code base. The former is safer and faster. Feel free to open such a PR :-)

git grep -E '(!=|==) *None' -- "*.py" is your friend.

@daniel-s-ingram
Copy link
Contributor Author

Will do - thanks, @practicalswift!

@practicalswift
Copy link
Contributor

practicalswift commented Dec 10, 2018

@daniel-s-ingram Great! When doing that don't forget to enable flake8 check E711 in test/lint/lint-python.sh to make sure your fix becomes permanent until the end of time :-)

And don't forget the technical rationale in the PR description: otherwise people who aren't familiar with how Python handles is vs == will incorrectly claim your fix is cosmetic :-)

@practicalswift
Copy link
Contributor

utACK c9ba253

@laanwj laanwj changed the title Handle exception as ImportError tests: Handle ImportError explicitly Dec 13, 2018
@laanwj laanwj changed the title tests: Handle ImportError explicitly tests: Handle ImportError explicitly, improve comparisons against None Dec 13, 2018
@laanwj
Copy link
Member

laanwj commented Dec 13, 2018

I think we should use is None/is not None instead of == None/!= None throughout the code base. The former is safer and faster. Feel free to open such a PR :-)

Agree. This is overall an improvement, IMO. I did change the PR title to be more comprehensible and in line with the actual changes.

utACK c9ba253

@laanwj laanwj merged commit c9ba253 into bitcoin:master Dec 13, 2018
laanwj added a commit that referenced this pull request Dec 13, 2018
…ns against None

c9ba253 Add E711 to flake8 check (Daniel Ingram)
17b5520 Compare to None with is/is not (Daniel Ingram)
1b89074 Change '== None' to 'is None' (Daniel Ingram)
16d2937 Handle exception as ImportError (Daniel Ingram)

Pull request description:

Tree-SHA512: aa5875ea3d9ac47ac898545ff023b511042cd377ea0c4594074daae119f3d4f3fc295721aad94a732a907086ecb32bce19a8eed38adf479f12663c4e8944f721
@@ -25,7 +25,7 @@
import codecs
try:
from urllib.request import Request,urlopen
except:
except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

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

This exception handling is a vestige from when github-merge.py supported Python 2 and Python 3. We only support Python 3 now so we should be able to remove it entirely and just import from urllib.request.

maflcko pushed a commit that referenced this pull request Dec 13, 2018
4de11a3 Remove Python 2 import workarounds (practicalswift)

Pull request description:

  Remove Python 2 import workarounds.

  As noted by @jnewbery in #14903 (comment):

  > This exception handling is a vestige from when github-merge.py supported Python 2 and Python 3. We only support Python 3 now so we should be able to remove it entirely and just import from urllib.request.

Tree-SHA512: e0d21e6299dd62fb669ad95cbd3d19f7c803195fd336621aac72fd10ddc7431d90443831072a2e1eb2fc880d1d88eb7c3e2ead3da59f545f6db07d349af98fb3
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 2, 2021
4de11a3 Remove Python 2 import workarounds (practicalswift)

Pull request description:

  Remove Python 2 import workarounds.

  As noted by @jnewbery in bitcoin#14903 (comment):

  > This exception handling is a vestige from when github-merge.py supported Python 2 and Python 3. We only support Python 3 now so we should be able to remove it entirely and just import from urllib.request.

Tree-SHA512: e0d21e6299dd62fb669ad95cbd3d19f7c803195fd336621aac72fd10ddc7431d90443831072a2e1eb2fc880d1d88eb7c3e2ead3da59f545f6db07d349af98fb3
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 3, 2021
4de11a3 Remove Python 2 import workarounds (practicalswift)

Pull request description:

  Remove Python 2 import workarounds.

  As noted by @jnewbery in bitcoin#14903 (comment):

  > This exception handling is a vestige from when github-merge.py supported Python 2 and Python 3. We only support Python 3 now so we should be able to remove it entirely and just import from urllib.request.

Tree-SHA512: e0d21e6299dd62fb669ad95cbd3d19f7c803195fd336621aac72fd10ddc7431d90443831072a2e1eb2fc880d1d88eb7c3e2ead3da59f545f6db07d349af98fb3
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 3, 2021
4de11a3 Remove Python 2 import workarounds (practicalswift)

Pull request description:

  Remove Python 2 import workarounds.

  As noted by @jnewbery in bitcoin#14903 (comment):

  > This exception handling is a vestige from when github-merge.py supported Python 2 and Python 3. We only support Python 3 now so we should be able to remove it entirely and just import from urllib.request.

Tree-SHA512: e0d21e6299dd62fb669ad95cbd3d19f7c803195fd336621aac72fd10ddc7431d90443831072a2e1eb2fc880d1d88eb7c3e2ead3da59f545f6db07d349af98fb3
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Aug 5, 2021
…mparisons against None

c9ba253 Add E711 to flake8 check (Daniel Ingram)
17b5520 Compare to None with is/is not (Daniel Ingram)
1b89074 Change '== None' to 'is None' (Daniel Ingram)
16d2937 Handle exception as ImportError (Daniel Ingram)

Pull request description:

Tree-SHA512: aa5875ea3d9ac47ac898545ff023b511042cd377ea0c4594074daae119f3d4f3fc295721aad94a732a907086ecb32bce19a8eed38adf479f12663c4e8944f721
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Aug 5, 2021
…mparisons against None

c9ba253 Add E711 to flake8 check (Daniel Ingram)
17b5520 Compare to None with is/is not (Daniel Ingram)
1b89074 Change '== None' to 'is None' (Daniel Ingram)
16d2937 Handle exception as ImportError (Daniel Ingram)

Pull request description:

Tree-SHA512: aa5875ea3d9ac47ac898545ff023b511042cd377ea0c4594074daae119f3d4f3fc295721aad94a732a907086ecb32bce19a8eed38adf479f12663c4e8944f721
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants