diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -21,7 +21,7 @@ "type": "flake8", "include": "(\\.py$)", "flags": [ - "--select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E271,E272,E273,E274,E275,E304,E306,E502,E702,E703,E714,E721,E741,E742,E743,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F822,F823,F831,W292,W601,W602,W603,W604" + "--select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E271,E272,E273,E274,E275,E304,E306,E502,E702,E703,E714,E721,E741,E742,E743,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F822,F823,F831,W292,W601,W602,W603,W604,W605" ] }, "lint-format-strings": { diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -72,7 +72,7 @@ ################################################################################ -COPYRIGHT_WITH_C = 'Copyright \(c\)' +COPYRIGHT_WITH_C = r'Copyright \(c\)' COPYRIGHT_WITHOUT_C = 'Copyright' ANY_COPYRIGHT_STYLE = '({}|{})'.format(COPYRIGHT_WITH_C, COPYRIGHT_WITHOUT_C) @@ -91,31 +91,31 @@ EXPECTED_HOLDER_NAMES = [ - "Satoshi Nakamoto\n", - "The Bitcoin Core developers\n", - "The Bitcoin Core developers \n", - "Bitcoin Core Developers\n", - "the Bitcoin Core developers\n", - "The Bitcoin developers\n", - "The LevelDB Authors\. All rights reserved\.\n", - "BitPay Inc\.\n", - "BitPay, Inc\.\n", - "University of Illinois at Urbana-Champaign\.\n", - "MarcoFalke\n", - "Pieter Wuille\n", - "Pieter Wuille +\*\n", - "Pieter Wuille, Gregory Maxwell +\*\n", - "Pieter Wuille, Andrew Poelstra +\*\n", - "Andrew Poelstra +\*\n", - "Wladimir J. van der Laan\n", - "Jeff Garzik\n", - "Diederik Huys, Pieter Wuille +\*\n", - "Thomas Daede, Cory Fields +\*\n", - "Jan-Klaas Kollhof\n", - "Sam Rushing\n", - "ArtForz -- public domain half-a-node\n", - "Amaury SÉCHET\n", - "Jeremy Rubin\n", + r"Satoshi Nakamoto\n", + r"The Bitcoin Core developers\n", + r"The Bitcoin Core developers \n", + r"Bitcoin Core Developers\n", + r"the Bitcoin Core developers\n", + r"The Bitcoin developers\n", + r"The LevelDB Authors\. All rights reserved\.\n", + r"BitPay Inc\.\n", + r"BitPay, Inc\.\n", + r"University of Illinois at Urbana-Champaign\.\n", + r"MarcoFalke\n", + r"Pieter Wuille\n", + r"Pieter Wuille +\*\n", + r"Pieter Wuille, Gregory Maxwell +\*\n", + r"Pieter Wuille, Andrew Poelstra +\*\n", + r"Andrew Poelstra +\*\n", + r"Wladimir J. van der Laan\n", + r"Jeff Garzik\n", + r"Diederik Huys, Pieter Wuille +\*\n", + r"Thomas Daede, Cory Fields +\*\n", + r"Jan-Klaas Kollhof\n", + r"Sam Rushing\n", + r"ArtForz -- public domain half-a-node\n", + r"Amaury SÉCHET\n", + r"Jeremy Rubin\n", ] DOMINANT_STYLE_COMPILED = {} @@ -368,7 +368,7 @@ ################################################################################ -COPYRIGHT = 'Copyright \(c\)' +COPYRIGHT = r'Copyright \(c\)' YEAR = "20[0-9][0-9]" YEAR_RANGE = '({})(-{})?'.format(YEAR, YEAR) HOLDER = 'The Bitcoin developers' diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -144,7 +144,7 @@ tokens = line.split() if len(tokens) > 2 and tokens[1] == '(NEEDED)': match = re.match( - '^Shared library: \[(.*)\]$', ' '.join(tokens[2:])) + r'^Shared library: \[(.*)\]$', ' '.join(tokens[2:])) if match: libraries.append(match.group(1)) else: diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py --- a/contrib/linearize/linearize-data.py +++ b/contrib/linearize/linearize-data.py @@ -284,12 +284,12 @@ f = open(sys.argv[1]) for line in f: # skip comment lines - m = re.search('^\s*#', line) + m = re.search(r'^\s*#', line) if m: continue # parse key=value lines - m = re.search('^(\w+)\s*=\s*(\S.*)$', line) + m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) if m is None: continue settings[m.group(1)] = m.group(2) diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py --- a/contrib/linearize/linearize-hashes.py +++ b/contrib/linearize/linearize-hashes.py @@ -119,12 +119,12 @@ f = open(sys.argv[1]) for line in f: # skip comment lines - m = re.search('^\s*#', line) + m = re.search(r'^\s*#', line) if m: continue # parse key=value lines - m = re.search('^(\w+)\s*=\s*(\S.*)$', line) + m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) if m is None: continue settings[m.group(1)] = m.group(2) diff --git a/test/functional/abc-cmdline.py b/test/functional/abc-cmdline.py --- a/test/functional/abc-cmdline.py +++ b/test/functional/abc-cmdline.py @@ -16,7 +16,7 @@ from test_framework.util import assert_equal MAX_GENERATED_BLOCK_SIZE_ERROR = ( - 'Max generated block size \(blockmaxsize\) cannot exceed the excessive block size \(excessiveblocksize\)') + r'Max generated block size \(blockmaxsize\) cannot exceed the excessive block size \(excessiveblocksize\)') class ABC_CmdLine_Test (BitcoinTestFramework): @@ -48,14 +48,14 @@ 2 * LEGACY_MAX_BLOCK_SIZE)]) self.check_excessive(2 * LEGACY_MAX_BLOCK_SIZE) # Check for EB correctness in the subver string - self.check_subversion("/Bitcoin ABC:.*\(EB2\.0; .*\)/") + self.check_subversion(r"/Bitcoin ABC:.*\(EB2\.0; .*\)/") self.log.info(" Attempt to set below legacy limit of 1MB - try {} bytes".format( LEGACY_MAX_BLOCK_SIZE)) self.stop_node(0) self.nodes[0].assert_start_raises_init_error( ["-excessiveblocksize={}".format(LEGACY_MAX_BLOCK_SIZE)], - 'Error: Excessive block size must be > 1,000,000 bytes \(1MB\)') + r'Error: Excessive block size must be > 1,000,000 bytes \(1MB\)') self.log.info(" Attempt to set below blockmaxsize (mining limit)") self.nodes[0].assert_start_raises_init_error( ['-blockmaxsize=1500000', '-excessiveblocksize=1300000'], 'Error: ' + MAX_GENERATED_BLOCK_SIZE_ERROR) diff --git a/test/functional/abc-rpc.py b/test/functional/abc-rpc.py --- a/test/functional/abc-rpc.py +++ b/test/functional/abc-rpc.py @@ -59,7 +59,7 @@ ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 2 * ONE_MEGABYTE) # Check for EB correctness in the subver string - self.check_subversion("/Bitcoin ABC:.*\(EB2\.0; .*\)/") + self.check_subversion(r"/Bitcoin ABC:.*\(EB2\.0; .*\)/") # Check setting to 13MB self.nodes[0].setexcessiveblock(13 * ONE_MEGABYTE) @@ -67,7 +67,7 @@ ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 13 * ONE_MEGABYTE) # Check for EB correctness in the subver string - self.check_subversion("/Bitcoin ABC:.*\(EB13\.0; .*\)/") + self.check_subversion(r"/Bitcoin ABC:.*\(EB13\.0; .*\)/") # Check setting to 13.14MB self.nodes[0].setexcessiveblock(13140000) @@ -75,7 +75,7 @@ ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 13.14 * ONE_MEGABYTE) # check for EB correctness in the subver string - self.check_subversion("/Bitcoin ABC:.*\(EB13\.1; .*\)/") + self.check_subversion(r"/Bitcoin ABC:.*\(EB13\.1; .*\)/") def run_test(self): self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) diff --git a/test/functional/feature_logging.py b/test/functional/feature_logging.py --- a/test/functional/feature_logging.py +++ b/test/functional/feature_logging.py @@ -33,7 +33,7 @@ invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo") invalidname = os.path.join("foo", "foo.log") self.stop_node(0) - exp_stderr = "Error: Could not open debug log file \S+$" + exp_stderr = r"Error: Could not open debug log file \S+$" self.nodes[0].assert_start_raises_init_error( ["-debuglogfile={}".format(invalidname)], exp_stderr) assert not os.path.isfile(os.path.join(invdir, "foo.log")) diff --git a/test/functional/feature_uacomment.py b/test/functional/feature_uacomment.py --- a/test/functional/feature_uacomment.py +++ b/test/functional/feature_uacomment.py @@ -27,14 +27,14 @@ self.log.info("test -uacomment max length") self.stop_node(0) - expected = "Error: Total length of network version string \([0-9]+\) exceeds maximum length \(256\). Reduce the number or size of uacomments." + expected = r"Error: Total length of network version string \([0-9]+\) exceeds maximum length \(256\). Reduce the number or size of uacomments." self.nodes[0].assert_start_raises_init_error( ["-uacomment=" + 'a' * 256], expected) self.log.info("test -uacomment unsafe characters") for unsafe_char in ['/', ':', '(', ')']: - expected = "Error: User Agent comment \(" + re.escape( - unsafe_char) + "\) contains unsafe characters." + expected = r"Error: User Agent comment \(" + re.escape( + unsafe_char) + r"\) contains unsafe characters." self.nodes[0].assert_start_raises_init_error( ["-uacomment=" + unsafe_char], expected) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -229,7 +229,7 @@ # in the all_scripts list. Accept the name with or without .py # extension. individual_tests = [ - re.sub("\.py$", "", t) + ".py" for t in tests if not t.endswith('*')] + re.sub(r"\.py$", "", t) + ".py" for t in tests if not t.endswith('*')] test_list = [] for t in individual_tests: if t in all_scripts: @@ -257,7 +257,7 @@ # Remove the test cases that the user has explicitly asked to exclude. if args.exclude: - tests_excl = [re.sub("\.py$", "", t) + + tests_excl = [re.sub(r"\.py$", "", t) + ".py" for t in args.exclude.split(',')] for exclude_test in tests_excl: if exclude_test in test_list: diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -85,14 +85,14 @@ # should not initialize if one wallet is a copy of another shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy')) - exp_stderr = "CDB: Can't open database w8_copy \(duplicates fileid \w+ from w8\)" + exp_stderr = r"CDB: Can't open database w8_copy \(duplicates fileid \w+ from w8\)" self.nodes[0].assert_start_raises_init_error( ['-wallet=w8', '-wallet=w8_copy'], exp_stderr, partial_match=True) # should not initialize if wallet file is a symlink os.symlink('w8', wallet_dir('w8_symlink')) self.nodes[0].assert_start_raises_init_error( - ['-wallet=w8_symlink'], 'Error: Invalid -wallet path \'w8_symlink\'\. .*') + ['-wallet=w8_symlink'], r'Error: Invalid -wallet path \'w8_symlink\'\. .*') # should not initialize if the specified walletdir does not exist self.nodes[0].assert_start_raises_init_error( @@ -124,7 +124,7 @@ self.options.tmpdir, 'competing_walletdir') os.mkdir(competing_wallet_dir) self.restart_node(0, ['-walletdir=' + competing_wallet_dir]) - exp_stderr = "Error: Error initializing wallet database environment \"\S+competing_walletdir\"!" + exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\"!" self.nodes[1].assert_start_raises_init_error( ['-walletdir=' + competing_wallet_dir], exp_stderr, partial_match=True) diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -21,8 +21,8 @@ FOLDER_TEST = '/src/**/test/' EXTENSIONS = ["*.c", "*.h", "*.cpp", "*.cc", "*.hpp"] -REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\(\s*"(-[^"]+)"' -REGEX_DOC = 'AddArg\(\s*"(-[^"=]+?)(?:=|")' +REGEX_ARG = r'(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\(\s*"(-[^"]+)"' +REGEX_DOC = r'AddArg\(\s*"(-[^"=]+?)(?:=|")' # list unsupported, deprecated and duplicate args as they need no documentation SET_DOC_OPTIONAL = set(['-benchmark', diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -74,7 +74,7 @@ assert(type(s) is str) s = s.replace("\n", " ") s = s.replace("\t", " ") - s = re.sub("/\*.*?\*/", " ", s) + s = re.sub(r"/\*.*?\*/", " ", s) s = re.sub(" {2,}", " ", s) return s.strip()