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

c9ba253f4f Add E711 to flake8 check (Daniel Ingram)
17b55202da Compare to None with is/is not (Daniel Ingram)
1b89074ae2 Change '== None' to 'is None' (Daniel Ingram)
16d2937723 Handle exception as ImportError (Daniel Ingram)

Pull request description:

Tree-SHA512: aa5875ea3d9ac47ac898545ff023b511042cd377ea0c4594074daae119f3d4f3fc295721aad94a732a907086ecb32bce19a8eed38adf479f12663c4e8944f721
This commit is contained in:
Wladimir J. van der Laan
2018-12-13 12:57:41 +01:00
9 changed files with 18 additions and 17 deletions

View File

@@ -109,7 +109,7 @@ def main():
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
if match:
filename = match.group(2)
if filename == None:
if filename is None:
continue
if args.regex is not None:

View File

@@ -491,7 +491,7 @@ def get_git_change_year_range(filename):
def file_already_has_core_copyright(file_lines):
index, _ = get_updatable_copyright_line(file_lines)
return index != None
return index is not None
################################################################################
# insert header execution

View File

@@ -25,7 +25,7 @@ import json
import codecs
try:
from urllib.request import Request,urlopen
except:
except ImportError:
from urllib2 import Request,urlopen
# External tools (can be overridden using environment)

View File

@@ -125,7 +125,7 @@ def escape_cdata(text):
return text
def contains_bitcoin_addr(text, errors):
if text != None and ADDRESS_REGEXP.search(text) != None:
if text is not None and ADDRESS_REGEXP.search(text) is not None:
errors.append('Translation "%s" contains a bitcoin address. This will be removed.' % (text))
return True
return False