summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2022-10-27 10:19:42 +1300
committerMike Taves <mwtoews@gmail.com>2022-10-27 10:38:56 +1300
commit69a39461de4da2bfc0e6aeeff02c73c0972a8614 (patch)
treecdab4df7d48c675a0961c4386dd3cd90d00dd22d
parent13d55a3c2f016a58a6e9d6b8086f338e07c7478f (diff)
downloadnumpy-69a39461de4da2bfc0e6aeeff02c73c0972a8614.tar.gz
MAINT: change subprocess arguments from Python>=3.7
-rw-r--r--benchmarks/asv_pip_nopep517.py2
-rw-r--r--numpy/distutils/ccompiler_opt.py2
-rw-r--r--numpy/distutils/exec_command.py7
-rw-r--r--numpy/distutils/lib2def.py2
-rw-r--r--numpy/distutils/misc_util.py2
-rw-r--r--numpy/f2py/__init__.py3
-rwxr-xr-xsetup.py4
7 files changed, 10 insertions, 12 deletions
diff --git a/benchmarks/asv_pip_nopep517.py b/benchmarks/asv_pip_nopep517.py
index 9ba165493..085cbff1f 100644
--- a/benchmarks/asv_pip_nopep517.py
+++ b/benchmarks/asv_pip_nopep517.py
@@ -5,7 +5,7 @@ import subprocess, sys
# pip ignores '--global-option' when pep517 is enabled therefore we disable it.
cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
- output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
+ output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True)
except Exception as e:
output = str(e.output)
if "no such option" in output:
diff --git a/numpy/distutils/ccompiler_opt.py b/numpy/distutils/ccompiler_opt.py
index 2019dcb25..5f18efc7d 100644
--- a/numpy/distutils/ccompiler_opt.py
+++ b/numpy/distutils/ccompiler_opt.py
@@ -747,7 +747,7 @@ class _Distutils:
def _dist_test_spawn(cmd, display=None):
try:
o = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
- universal_newlines=True)
+ text=True)
if o and re.match(_Distutils._dist_warn_regex, o):
_Distutils.dist_error(
"Flags in command", cmd ,"aren't supported by the compiler"
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py
index 79998cf5d..a67453abf 100644
--- a/numpy/distutils/exec_command.py
+++ b/numpy/distutils/exec_command.py
@@ -276,14 +276,13 @@ def _exec_command(command, use_shell=None, use_tee = None, **env):
# Inherit environment by default
env = env or None
try:
- # universal_newlines is set to False so that communicate()
+ # text is set to False so that communicate()
# will return bytes. We need to decode the output ourselves
# so that Python will not raise a UnicodeDecodeError when
# it encounters an invalid character; rather, we simply replace it
- proc = subprocess.Popen(command, shell=use_shell, env=env,
+ proc = subprocess.Popen(command, shell=use_shell, env=env, text=False,
stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- universal_newlines=False)
+ stderr=subprocess.STDOUT)
except OSError:
# Return 127, as os.spawn*() and /bin/sh do
return 127, ''
diff --git a/numpy/distutils/lib2def.py b/numpy/distutils/lib2def.py
index 820ed71f5..851682c63 100644
--- a/numpy/distutils/lib2def.py
+++ b/numpy/distutils/lib2def.py
@@ -64,7 +64,7 @@ def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, universal_newlines=True)
+ stderr=subprocess.PIPE, text=True)
nm_output, nm_err = p.communicate()
if p.returncode != 0:
raise RuntimeError('failed to run "%s": "%s"' % (
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index b3916a2c8..79ba08515 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -416,7 +416,7 @@ def cyg2win32(path: str) -> str:
if sys.platform != "cygwin":
return path
return subprocess.check_output(
- ["/usr/bin/cygpath", "--windows", path], universal_newlines=True
+ ["/usr/bin/cygpath", "--windows", path], text=True
)
diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py
index 84192f738..dbe3df27f 100644
--- a/numpy/f2py/__init__.py
+++ b/numpy/f2py/__init__.py
@@ -104,8 +104,7 @@ def compile(source,
'-c',
'import numpy.f2py as f2py2e;f2py2e.main()'] + args
try:
- cp = subprocess.run(c, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ cp = subprocess.run(c, capture_output=True)
except OSError:
# preserve historic status code used by exec_command()
cp = subprocess.CompletedProcess(c, 127, stdout=b'', stderr=b'')
diff --git a/setup.py b/setup.py
index 449507334..a1e495832 100755
--- a/setup.py
+++ b/setup.py
@@ -219,8 +219,8 @@ def get_build_overrides():
return False
# will print something like '4.2.1\n'
- out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, universal_newlines=True)
+ out = subprocess.run([cc, '-dumpversion'],
+ capture_output=True, text=True)
# -std=c99 is default from this version on
if _pep440.parse(out.stdout) >= _pep440.Version('5.0'):
return False