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

pull daniel-s-ingram wants to merge 4 commits into bitcoin:master from daniel-s-ingram:master changing 9 files +18 −17
  1. daniel-s-ingram commented at 8:50 PM on December 9, 2018: contributor

    No description provided.

  2. Handle exception as ImportError 16d2937723
  3. Change '== None' to 'is None' 1b89074ae2
  4. fanquake added the label Scripts and tools on Dec 9, 2018
  5. jonasschnelli commented at 11:00 PM on December 9, 2018: contributor

    meh ACK

  6. practicalswift commented at 7:27 PM on December 10, 2018: contributor

    ACK 1b89074ae27ce123adbeed57343deaef13c14f81

    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.

  7. daniel-s-ingram commented at 7:33 PM on December 10, 2018: contributor

    Will do - thanks, @practicalswift!

  8. practicalswift commented at 7:41 PM on December 10, 2018: contributor

    @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 :-)

  9. Compare to None with is/is not 17b55202da
  10. Add E711 to flake8 check c9ba253f4f
  11. practicalswift commented at 8:26 PM on December 10, 2018: contributor

    utACK c9ba253f4f5d675d7736d24c1167229d0898ef1a

  12. laanwj renamed this:
    Handle exception as ImportError
    tests: Handle ImportError explicitly
    on Dec 13, 2018
  13. laanwj renamed this:
    tests: Handle ImportError explicitly
    tests: Handle ImportError explicitly, improve comparisons against None
    on Dec 13, 2018
  14. laanwj commented at 11:58 AM on December 13, 2018: member

    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 c9ba253f4f5d675d7736d24c1167229d0898ef1a

  15. laanwj merged this on Dec 13, 2018
  16. laanwj closed this on Dec 13, 2018

  17. laanwj referenced this in commit f17aca67b0 on Dec 13, 2018
  18. in contrib/devtools/github-merge.py:28 in c9ba253f4f
      24 | @@ -25,7 +25,7 @@
      25 |  import codecs
      26 |  try:
      27 |      from urllib.request import Request,urlopen
      28 | -except:
      29 | +except ImportError:
    


    jnewbery commented at 1:23 PM on December 13, 2018:

    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.

  19. MarcoFalke referenced this in commit 9a43344430 on Dec 13, 2018
  20. pravblockc referenced this in commit 9dd702cd5a on Aug 2, 2021
  21. pravblockc referenced this in commit a41ca898dc on Aug 3, 2021
  22. pravblockc referenced this in commit a309982e82 on Aug 3, 2021
  23. Munkybooty referenced this in commit 5edce02d5f on Aug 5, 2021
  24. Munkybooty referenced this in commit 7e64c688fe on Aug 5, 2021
  25. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 18:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me