Skip to content

Commit fa8fe5b

Browse files
author
MarcoFalke
committed
scripted-diff: Use new python 3.7 keywords
-BEGIN VERIFY SCRIPT- sed -i 's/universal_newlines/text/g' $(git grep -l universal_newlines) -END VERIFY SCRIPT-
1 parent fa2a235 commit fa8fe5b

23 files changed

+47
-47
lines changed

contrib/devtools/clang-format-diff.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def main():
146146
stdout=subprocess.PIPE,
147147
stderr=None,
148148
stdin=subprocess.PIPE,
149-
universal_newlines=True)
149+
text=True)
150150
stdout, stderr = p.communicate()
151151
if p.returncode != 0:
152152
sys.exit(p.returncode)

contrib/devtools/gen-manpages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# If not otherwise specified, get top directory from git.
2424
topdir = os.getenv('TOPDIR')
2525
if not topdir:
26-
r = subprocess.run([git, 'rev-parse', '--show-toplevel'], stdout=subprocess.PIPE, check=True, universal_newlines=True)
26+
r = subprocess.run([git, 'rev-parse', '--show-toplevel'], stdout=subprocess.PIPE, check=True, text=True)
2727
topdir = r.stdout.rstrip()
2828

2929
# Get input and output directories.
@@ -36,7 +36,7 @@
3636
for relpath in BINARIES:
3737
abspath = os.path.join(builddir, relpath)
3838
try:
39-
r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, universal_newlines=True)
39+
r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, text=True)
4040
except IOError:
4141
print(f'{abspath} not found or not an executable', file=sys.stderr)
4242
sys.exit(1)

contrib/devtools/test-security-check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def call_security_check(cc, source, executable, options):
3939
env_flags += filter(None, os.environ.get(var, '').split(' '))
4040

4141
subprocess.run([*cc,source,'-o',executable] + env_flags + options, check=True)
42-
p = subprocess.run([os.path.join(os.path.dirname(__file__), 'security-check.py'), executable], stdout=subprocess.PIPE, universal_newlines=True)
42+
p = subprocess.run([os.path.join(os.path.dirname(__file__), 'security-check.py'), executable], stdout=subprocess.PIPE, text=True)
4343
return (p.returncode, p.stdout.rstrip())
4444

4545
def get_arch(cc, source, executable):

contrib/devtools/test-symbol-check.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def call_symbol_check(cc: List[str], source, executable, options):
2323
env_flags += filter(None, os.environ.get(var, '').split(' '))
2424

2525
subprocess.run([*cc,source,'-o',executable] + env_flags + options, check=True)
26-
p = subprocess.run([os.path.join(os.path.dirname(__file__), 'symbol-check.py'), executable], stdout=subprocess.PIPE, universal_newlines=True)
26+
p = subprocess.run([os.path.join(os.path.dirname(__file__), 'symbol-check.py'), executable], stdout=subprocess.PIPE, text=True)
2727
os.remove(source)
2828
os.remove(executable)
2929
return (p.returncode, p.stdout.rstrip())
3030

3131
def get_machine(cc: List[str]):
32-
p = subprocess.run([*cc,'-dumpmachine'], stdout=subprocess.PIPE, universal_newlines=True)
32+
p = subprocess.run([*cc,'-dumpmachine'], stdout=subprocess.PIPE, text=True)
3333
return p.stdout.rstrip()
3434

3535
class TestSymbolChecks(unittest.TestCase):

contrib/macdeploy/macdeployqtplus

+5-5
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]:
187187
if verbose:
188188
print(f"Inspecting with otool: {binaryPath}")
189189
otoolbin=os.getenv("OTOOL", "otool")
190-
otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, universal_newlines=True)
190+
otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, text=True)
191191
if otool.returncode != 0:
192192
sys.stderr.write(otool.stderr)
193193
sys.stderr.flush()
@@ -577,17 +577,17 @@ if config.dmg is not None:
577577

578578
tempname: str = appname + ".temp.dmg"
579579

580-
run(["hdiutil", "create", tempname, "-srcfolder", "dist", "-format", "UDRW", "-size", str(size), "-volname", appname], check=True, universal_newlines=True)
580+
run(["hdiutil", "create", tempname, "-srcfolder", "dist", "-format", "UDRW", "-size", str(size), "-volname", appname], check=True, text=True)
581581

582582
if verbose:
583583
print("Attaching temp image...")
584-
output = run(["hdiutil", "attach", tempname, "-readwrite"], check=True, universal_newlines=True, stdout=PIPE).stdout
584+
output = run(["hdiutil", "attach", tempname, "-readwrite"], check=True, text=True, stdout=PIPE).stdout
585585

586586
print("+ Finalizing .dmg disk image +")
587587

588-
run(["hdiutil", "detach", f"/Volumes/{appname}"], universal_newlines=True)
588+
run(["hdiutil", "detach", f"/Volumes/{appname}"], text=True)
589589

590-
run(["hdiutil", "convert", tempname, "-format", "UDZO", "-o", appname, "-imagekey", "zlib-level=9"], check=True, universal_newlines=True)
590+
run(["hdiutil", "convert", tempname, "-format", "UDZO", "-o", appname, "-imagekey", "zlib-level=9"], check=True, text=True)
591591

592592
os.unlink(tempname)
593593

test/functional/rpc_users.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def setup_chain(self):
5353

5454
# Generate RPCAUTH with specified password
5555
self.rt2password = "8/F3uMDw4KSEbw96U3CA1C4X05dkHDN2BPFjTgZW4KI="
56-
p = subprocess.Popen([sys.executable, gen_rpcauth, 'rt2', self.rt2password], stdout=subprocess.PIPE, universal_newlines=True)
56+
p = subprocess.Popen([sys.executable, gen_rpcauth, 'rt2', self.rt2password], stdout=subprocess.PIPE, text=True)
5757
lines = p.stdout.read().splitlines()
5858
rpcauth2 = lines[1]
5959

6060
# Generate RPCAUTH without specifying password
6161
self.user = ''.join(SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(10))
62-
p = subprocess.Popen([sys.executable, gen_rpcauth, self.user], stdout=subprocess.PIPE, universal_newlines=True)
62+
p = subprocess.Popen([sys.executable, gen_rpcauth, self.user], stdout=subprocess.PIPE, text=True)
6363
lines = p.stdout.read().splitlines()
6464
rpcauth3 = lines[1]
6565
self.password = lines[3]

test/functional/test_framework/test_node.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ def send_cli(self, command=None, *args, **kwargs):
730730
p_args += [command]
731731
p_args += pos_args + named_args
732732
self.log.debug("Running bitcoin-cli {}".format(p_args[2:]))
733-
process = subprocess.Popen(p_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
733+
process = subprocess.Popen(p_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
734734
cli_stdout, cli_stderr = process.communicate(input=self.input)
735735
returncode = process.poll()
736736
if returncode:

test/functional/test_runner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
585585
combined_logs_args = [sys.executable, os.path.join(tests_dir, 'combine_logs.py'), testdir]
586586
if BOLD[0]:
587587
combined_logs_args += ['--color']
588-
combined_logs, _ = subprocess.Popen(combined_logs_args, universal_newlines=True, stdout=subprocess.PIPE).communicate()
588+
combined_logs, _ = subprocess.Popen(combined_logs_args, text=True, stdout=subprocess.PIPE).communicate()
589589
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len)))
590590

591591
if failfast:
@@ -670,7 +670,7 @@ def get_next(self):
670670
self.jobs.append((test,
671671
time.time(),
672672
subprocess.Popen([sys.executable, self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg,
673-
universal_newlines=True,
673+
text=True,
674674
stdout=log_stdout,
675675
stderr=log_stderr),
676676
testdir,

test/functional/tool_wallet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def bitcoin_wallet_process(self, *args):
3737
if not self.options.descriptors and 'create' in args:
3838
default_args.append('-legacy')
3939

40-
return subprocess.Popen([binary] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
40+
return subprocess.Popen([binary] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
4141

4242
def assert_raises_tool_error(self, error, *args):
4343
p = self.bitcoin_wallet_process(*args)

test/fuzz/test_runner.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def main():
143143
timeout=20,
144144
check=True,
145145
stderr=subprocess.PIPE,
146-
universal_newlines=True,
146+
text=True,
147147
).stderr
148148
if "libFuzzer" not in help_output:
149149
logging.error("Must be built with libFuzzer")
@@ -200,7 +200,7 @@ def job(command, t):
200200
env=get_fuzz_env(target=t, source_dir=src_dir),
201201
check=True,
202202
stderr=subprocess.PIPE,
203-
universal_newlines=True,
203+
text=True,
204204
).stderr))
205205

206206
futures = []
@@ -241,7 +241,7 @@ def job(t, args):
241241
env=get_fuzz_env(target=t, source_dir=src_dir),
242242
check=True,
243243
stderr=subprocess.PIPE,
244-
universal_newlines=True,
244+
text=True,
245245
).stderr
246246
logging.debug(output)
247247

@@ -270,7 +270,7 @@ def job(t, args):
270270
args,
271271
env=get_fuzz_env(target=t, source_dir=src_dir),
272272
stderr=subprocess.PIPE,
273-
universal_newlines=True,
273+
text=True,
274274
)
275275
output += result.stderr
276276
return output, result
@@ -299,7 +299,7 @@ def parse_test_list(*, fuzz_bin):
299299
},
300300
stdout=subprocess.PIPE,
301301
stderr=subprocess.DEVNULL,
302-
universal_newlines=True,
302+
text=True,
303303
).stdout.splitlines()
304304
return test_list_all
305305

test/lint/lint-assertions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def git_grep(params: [], error_msg: ""):
1414
try:
15-
output = subprocess.check_output(["git", "grep", *params], universal_newlines=True, encoding="utf8")
15+
output = subprocess.check_output(["git", "grep", *params], text=True, encoding="utf8")
1616
print(error_msg)
1717
print(output)
1818
return 1

test/lint/lint-circular-dependencies.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def main():
3838
os.chdir(CODE_DIR)
3939
files = subprocess.check_output(
4040
['git', 'ls-files', '--', '*.h', '*.cpp'],
41-
universal_newlines=True,
41+
text=True,
4242
).splitlines()
4343

4444
command = [sys.executable, "../contrib/devtools/circular-dependencies.py", *files]
4545
dependencies_output = subprocess.run(
4646
command,
4747
stdout=subprocess.PIPE,
48-
universal_newlines=True,
48+
text=True,
4949
)
5050

5151
for dependency_str in dependencies_output.stdout.rstrip().split("\n"):

test/lint/lint-git-commit-check.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ def main():
4242
commit_range = "HEAD~" + args.prev_commits + "...HEAD"
4343
else:
4444
# This assumes that the target branch of the pull request will be master.
45-
merge_base = check_output(["git", "merge-base", "HEAD", "master"], universal_newlines=True, encoding="utf8").rstrip("\n")
45+
merge_base = check_output(["git", "merge-base", "HEAD", "master"], text=True, encoding="utf8").rstrip("\n")
4646
commit_range = merge_base + "..HEAD"
4747
else:
4848
commit_range = os.getenv("COMMIT_RANGE")
4949
if commit_range == "SKIP_EMPTY_NOT_A_PR":
5050
sys.exit(0)
5151

52-
commit_hashes = check_output(["git", "log", commit_range, "--format=%H"], universal_newlines=True, encoding="utf8").splitlines()
52+
commit_hashes = check_output(["git", "log", commit_range, "--format=%H"], text=True, encoding="utf8").splitlines()
5353

5454
for hash in commit_hashes:
55-
commit_info = check_output(["git", "log", "--format=%B", "-n", "1", hash], universal_newlines=True, encoding="utf8").splitlines()
55+
commit_info = check_output(["git", "log", "--format=%B", "-n", "1", hash], text=True, encoding="utf8").splitlines()
5656
if len(commit_info) >= 2:
5757
if commit_info[1]:
5858
print(f"The subject line of commit hash {hash} is followed by a non-empty line. Subject lines should always be followed by a blank line.")

test/lint/lint-includes.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535

3636

3737
def get_toplevel():
38-
return check_output(["git", "rev-parse", "--show-toplevel"], universal_newlines=True, encoding="utf8").rstrip("\n")
38+
return check_output(["git", "rev-parse", "--show-toplevel"], text=True, encoding="utf8").rstrip("\n")
3939

4040

4141
def list_files_by_suffix(suffixes):
4242
exclude_args = [":(exclude)" + dir for dir in EXCLUDED_DIRS]
4343

44-
files_list = check_output(["git", "ls-files", "src"] + exclude_args, universal_newlines=True, encoding="utf8").splitlines()
44+
files_list = check_output(["git", "ls-files", "src"] + exclude_args, text=True, encoding="utf8").splitlines()
4545

4646
return [file for file in files_list if file.endswith(suffixes)]
4747

@@ -63,7 +63,7 @@ def find_included_cpps():
6363
included_cpps = list()
6464

6565
try:
66-
included_cpps = check_output(["git", "grep", "-E", r"^#include [<\"][^>\"]+\.cpp[>\"]", "--", "*.cpp", "*.h"], universal_newlines=True, encoding="utf8").splitlines()
66+
included_cpps = check_output(["git", "grep", "-E", r"^#include [<\"][^>\"]+\.cpp[>\"]", "--", "*.cpp", "*.h"], text=True, encoding="utf8").splitlines()
6767
except CalledProcessError as e:
6868
if e.returncode > 1:
6969
raise e
@@ -77,7 +77,7 @@ def find_extra_boosts():
7777
exclusion_set = set()
7878

7979
try:
80-
included_boosts = check_output(["git", "grep", "-E", r"^#include <boost/", "--", "*.cpp", "*.h"], universal_newlines=True, encoding="utf8").splitlines()
80+
included_boosts = check_output(["git", "grep", "-E", r"^#include <boost/", "--", "*.cpp", "*.h"], text=True, encoding="utf8").splitlines()
8181
except CalledProcessError as e:
8282
if e.returncode > 1:
8383
raise e
@@ -100,7 +100,7 @@ def find_quote_syntax_inclusions():
100100
quote_syntax_inclusions = list()
101101

102102
try:
103-
quote_syntax_inclusions = check_output(["git", "grep", r"^#include \"", "--", "*.cpp", "*.h"] + exclude_args, universal_newlines=True, encoding="utf8").splitlines()
103+
quote_syntax_inclusions = check_output(["git", "grep", r"^#include \"", "--", "*.cpp", "*.h"] + exclude_args, text=True, encoding="utf8").splitlines()
104104
except CalledProcessError as e:
105105
if e.returncode > 1:
106106
raise e
@@ -143,13 +143,13 @@ def main():
143143
if extra_boosts:
144144
for boost in extra_boosts:
145145
print(f"A new Boost dependency in the form of \"{boost}\" appears to have been introduced:")
146-
print(check_output(["git", "grep", boost, "--", "*.cpp", "*.h"], universal_newlines=True, encoding="utf8"))
146+
print(check_output(["git", "grep", boost, "--", "*.cpp", "*.h"], text=True, encoding="utf8"))
147147
exit_code = 1
148148

149149
# Check if Boost dependencies are no longer used
150150
for expected_boost in EXPECTED_BOOST_INCLUDES:
151151
try:
152-
check_output(["git", "grep", "-q", r"^#include <%s>" % expected_boost, "--", "*.cpp", "*.h"], universal_newlines=True, encoding="utf8")
152+
check_output(["git", "grep", "-q", r"^#include <%s>" % expected_boost, "--", "*.cpp", "*.h"], text=True, encoding="utf8")
153153
except CalledProcessError as e:
154154
if e.returncode > 1:
155155
raise e

test/lint/lint-locale-dependence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def find_locale_dependent_function_uses():
223223
git_grep_output = list()
224224

225225
try:
226-
git_grep_output = check_output(git_grep_command, universal_newlines=True, encoding="utf8").splitlines()
226+
git_grep_output = check_output(git_grep_command, text=True, encoding="utf8").splitlines()
227227
except CalledProcessError as e:
228228
if e.returncode > 1:
229229
raise e

test/lint/lint-logs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def main():
19-
logs_list = check_output(["git", "grep", "--extended-regexp", r"(LogPrintLevel|LogPrintfCategory|LogPrintf?)\(", "--", "*.cpp"], universal_newlines=True, encoding="utf8").splitlines()
19+
logs_list = check_output(["git", "grep", "--extended-regexp", r"(LogPrintLevel|LogPrintfCategory|LogPrintf?)\(", "--", "*.cpp"], text=True, encoding="utf8").splitlines()
2020

2121
unterminated_logs = [line for line in logs_list if not re.search(r'(\\n"|/\* Continued \*/)', line)]
2222

test/lint/lint-python-mutable-default-parameters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main():
2121
"--",
2222
"*.py",
2323
]
24-
output = subprocess.run(command, stdout=subprocess.PIPE, universal_newlines=True)
24+
output = subprocess.run(command, stdout=subprocess.PIPE, text=True)
2525
if len(output.stdout) > 0:
2626
error_msg = (
2727
"A mutable list or dict seems to be used as default parameter value:\n\n"

test/lint/lint-python-utf8-encoding.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check_fileopens():
2323
fileopens = list()
2424

2525
try:
26-
fileopens = check_output(["git", "grep", r" open(", "--", "*.py"] + get_exclude_args(), universal_newlines=True, encoding="utf8").splitlines()
26+
fileopens = check_output(["git", "grep", r" open(", "--", "*.py"] + get_exclude_args(), text=True, encoding="utf8").splitlines()
2727
except CalledProcessError as e:
2828
if e.returncode > 1:
2929
raise e
@@ -37,12 +37,12 @@ def check_checked_outputs():
3737
checked_outputs = list()
3838

3939
try:
40-
checked_outputs = check_output(["git", "grep", "check_output(", "--", "*.py"] + get_exclude_args(), universal_newlines=True, encoding="utf8").splitlines()
40+
checked_outputs = check_output(["git", "grep", "check_output(", "--", "*.py"] + get_exclude_args(), text=True, encoding="utf8").splitlines()
4141
except CalledProcessError as e:
4242
if e.returncode > 1:
4343
raise e
4444

45-
filtered_checked_outputs = [checked_output for checked_output in checked_outputs if re.search(r"universal_newlines=True", checked_output) and not re.search(r"encoding=.(ascii|utf8|utf-8).", checked_output)]
45+
filtered_checked_outputs = [checked_output for checked_output in checked_outputs if re.search(r"text=True", checked_output) and not re.search(r"encoding=.(ascii|utf8|utf-8).", checked_output)]
4646

4747
return filtered_checked_outputs
4848

test/lint/lint-shell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def check_shellcheck_install():
2525
sys.exit(0)
2626

2727
def get_files(command):
28-
output = subprocess.run(command, stdout=subprocess.PIPE, universal_newlines=True)
28+
output = subprocess.run(command, stdout=subprocess.PIPE, text=True)
2929
files = output.stdout.split('\n')
3030

3131
# remove whitespace element

test/lint/lint-submodule.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def main():
1515
submodules_list = subprocess.check_output(['git', 'submodule', 'status', '--recursive'],
16-
universal_newlines = True, encoding = 'utf8').rstrip('\n')
16+
text = True, encoding = 'utf8').rstrip('\n')
1717
if submodules_list:
1818
print("These submodules were found, delete them:\n", submodules_list)
1919
sys.exit(1)

test/lint/lint-tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def grep_boost_fixture_test_suite():
2323
"src/test/**.cpp",
2424
"src/wallet/test/**.cpp",
2525
]
26-
return subprocess.check_output(command, universal_newlines=True, encoding="utf8")
26+
return subprocess.check_output(command, text=True, encoding="utf8")
2727

2828

2929
def check_matching_test_names(test_suite_list):

test/lint/lint-whitespace.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_diff(commit_range, check_only_code):
8080
else:
8181
what_files = ["."]
8282

83-
diff = check_output(["git", "diff", "-U0", commit_range, "--"] + what_files + exclude_args, universal_newlines=True, encoding="utf8")
83+
diff = check_output(["git", "diff", "-U0", commit_range, "--"] + what_files + exclude_args, text=True, encoding="utf8")
8484

8585
return diff
8686

@@ -93,7 +93,7 @@ def main():
9393
commit_range = "HEAD~" + args.prev_commits + "...HEAD"
9494
else:
9595
# This assumes that the target branch of the pull request will be master.
96-
merge_base = check_output(["git", "merge-base", "HEAD", "master"], universal_newlines=True, encoding="utf8").rstrip("\n")
96+
merge_base = check_output(["git", "merge-base", "HEAD", "master"], text=True, encoding="utf8").rstrip("\n")
9797
commit_range = merge_base + "..HEAD"
9898
else:
9999
commit_range = os.getenv("COMMIT_RANGE")

test/util/test_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def bctest(testDir, testObj, buildenv):
107107
raise Exception
108108

109109
# Run the test
110-
proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
110+
proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
111111
try:
112112
outs = proc.communicate(input=inputData)
113113
except OSError:

0 commit comments

Comments
 (0)