From 751f84405eb1138b7a9b75bfb51be161a62057e4 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 15 Aug 2021 11:34:11 -0400 Subject: [PATCH] pyupgrade --py37-plus --- mesonbuild/dependencies/hdf5.py | 2 +- run_meson_command_tests.py | 2 +- run_project_tests.py | 3 +-- unittests/baseplatformtests.py | 2 +- unittests/linuxliketests.py | 2 +- unittests/rewritetests.py | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py index 78ef9d683..2f1ed0a6b 100644 --- a/mesonbuild/dependencies/hdf5.py +++ b/mesonbuild/dependencies/hdf5.py @@ -164,7 +164,7 @@ def hdf5_factory(env: 'Environment', for_machine: 'MachineChoice', if PCEXE: # some distros put hdf5-1.2.3.pc with version number in .pc filename. ret = subprocess.run([PCEXE, '--list-all'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, - universal_newlines=True) + text=True) if ret.returncode == 0: for pkg in ret.stdout.split('\n'): if pkg.startswith('hdf5'): diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py index 45096c607..36cb02e2e 100755 --- a/run_meson_command_tests.py +++ b/run_meson_command_tests.py @@ -70,7 +70,7 @@ class CommandTests(unittest.TestCase): # between CI issue and test bug in that case. Set timeout and fail loud # instead. p = subprocess.run(command, stdout=subprocess.PIPE, - env=os.environ.copy(), universal_newlines=True, + env=os.environ.copy(), text=True, cwd=workdir, timeout=60 * 5) print(p.stdout) if p.returncode != 0: diff --git a/run_project_tests.py b/run_project_tests.py index 822cf0bd4..5fea66040 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -926,8 +926,7 @@ def have_d_compiler() -> bool: # that exists but segfaults every time the compiler is run. # Don't know why. Don't know how to fix. Skip in this case. cp = subprocess.run(['dmd', '--version'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + capture_output=True) if cp.stdout == b'': return False return True diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index bd2f9021b..2f8064e46 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -160,7 +160,7 @@ class BasePlatformTests(TestCase): p = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, encoding='utf-8', - universal_newlines=True, cwd=workdir, timeout=60 * 5) + text=True, cwd=workdir, timeout=60 * 5) print(p.stdout) if p.returncode != 0: if 'MESON_SKIP_TEST' in p.stdout: diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 594e9f0cc..ade489d83 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -1717,7 +1717,7 @@ class LinuxlikeTests(BasePlatformTests): p = subprocess.run([ar, 't', outlib], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, - universal_newlines=True, timeout=1) + text=True, timeout=1) obj_files = p.stdout.strip().split('\n') self.assertEqual(len(obj_files), 1) self.assertTrue(obj_files[0].endswith('-prelink.o')) diff --git a/unittests/rewritetests.py b/unittests/rewritetests.py index 1e6a3988b..1d90f2ad7 100644 --- a/unittests/rewritetests.py +++ b/unittests/rewritetests.py @@ -32,8 +32,8 @@ class RewriterTests(BasePlatformTests): if isinstance(args, str): args = [args] command = self.rewrite_command + ['--verbose', '--skip', '--sourcedir', directory] + args - p = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=True, timeout=60) + p = subprocess.run(command, capture_output=True, + text=True, timeout=60) print('STDOUT:') print(p.stdout) print('STDERR:')