Skip to content

Commit

Permalink
Compare to None with is/is not
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-s-ingram committed Dec 10, 2018
1 parent 1b89074 commit 17b5520
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contrib/devtools/copyright_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/devtools/update-translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/functional/interface_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def run_test(self):
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1)
assert(conn.sock!=None) #according to http/1.1 connection must still be open!
assert(conn.sock is not None) #according to http/1.1 connection must still be open!

#send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1) #must also response with a correct json-rpc message
assert(conn.sock!=None) #according to http/1.1 connection must still be open!
assert(conn.sock is not None) #according to http/1.1 connection must still be open!
conn.close()

#same should be if we add keep-alive because this should be the std. behaviour
Expand All @@ -48,13 +48,13 @@ def run_test(self):
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1)
assert(conn.sock!=None) #according to http/1.1 connection must still be open!
assert(conn.sock is not None) #according to http/1.1 connection must still be open!

#send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1) #must also response with a correct json-rpc message
assert(conn.sock!=None) #according to http/1.1 connection must still be open!
assert(conn.sock is not None) #according to http/1.1 connection must still be open!
conn.close()

#now do the same with "Connection: close"
Expand All @@ -65,7 +65,7 @@ def run_test(self):
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1)
assert(conn.sock==None) #now the connection must be closed after the response
assert(conn.sock is None) #now the connection must be closed after the response

#node1 (2nd node) is running with disabled keep-alive option
urlNode1 = urllib.parse.urlparse(self.nodes[1].url)
Expand All @@ -88,7 +88,7 @@ def run_test(self):
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1)
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
assert(conn.sock is not None) #connection must be closed because bitcoind should use keep-alive by default

# Check excessive request size
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/mining_prioritisetransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run_test(self):
high_fee_tx = x

# Something high-fee should have been mined!
assert(high_fee_tx != None)
assert(high_fee_tx is not None)

# Add a prioritisation before a tx is in the mempool (de-prioritising a
# high-fee transaction so that it's now low fee).
Expand Down
8 changes: 4 additions & 4 deletions test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def __init__(self, p2pheaders_and_shortids = None):
self.prefilled_txn = []
self.use_witness = False

if p2pheaders_and_shortids != None:
if p2pheaders_and_shortids is not None:
self.header = p2pheaders_and_shortids.header
self.nonce = p2pheaders_and_shortids.nonce
self.shortids = p2pheaders_and_shortids.shortids
Expand Down Expand Up @@ -822,7 +822,7 @@ class BlockTransactionsRequest:

def __init__(self, blockhash=0, indexes = None):
self.blockhash = blockhash
self.indexes = indexes if indexes != None else []
self.indexes = indexes if indexes is not None else []

def deserialize(self, f):
self.blockhash = deser_uint256(f)
Expand Down Expand Up @@ -863,7 +863,7 @@ class BlockTransactions:

def __init__(self, blockhash=0, transactions = None):
self.blockhash = blockhash
self.transactions = transactions if transactions != None else []
self.transactions = transactions if transactions is not None else []

def deserialize(self, f):
self.blockhash = deser_uint256(f)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ class msg_getdata:
command = b"getdata"

def __init__(self, inv=None):
self.inv = inv if inv != None else []
self.inv = inv if inv is not None else []

def deserialize(self, f):
self.inv = deser_vector(f, CInv)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mock
self.rpc_timeout = timewait
self.binary = bitcoind
self.coverage_dir = coverage_dir
if extra_conf != None:
if extra_conf is not None:
append_config(datadir, extra_conf)
# Most callers will just need to add extra args to the standard list below.
# For those callers that need more flexibility, they can just set the args property directly.
Expand Down

0 comments on commit 17b5520

Please sign in to comment.