bpo-35952: Fix test.pythoninfo when the compiler is missing (GH-13007)

https://github.com/python/cpython/commit/a86e06433a010f873dfd7957e0f87a39539... commit: a86e06433a010f873dfd7957e0f87a39539876ee branch: master author: xdegaye <xdegaye@gmail.com> committer: Victor Stinner <vstinner@redhat.com> date: 2019-04-29T14:53:30+02:00 summary: bpo-35952: Fix test.pythoninfo when the compiler is missing (GH-13007) files: A Misc/NEWS.d/next/Library/2019-04-29-11-47-06.bpo-35952.3uNuyo.rst M Lib/test/pythoninfo.py diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 19f274a6b629..580956633f4d 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -571,10 +571,17 @@ def collect_cc(info_add): except ImportError: args = CC.split() args.append('--version') - proc = subprocess.Popen(args, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - universal_newlines=True) + try: + proc = subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True) + except OSError: + # Cannot run the compiler, for example when Python has been + # cross-compiled and installed on the target platform where the + # compiler is missing. + return + stdout = proc.communicate()[0] if proc.returncode: # CC --version failed: ignore error diff --git a/Misc/NEWS.d/next/Library/2019-04-29-11-47-06.bpo-35952.3uNuyo.rst b/Misc/NEWS.d/next/Library/2019-04-29-11-47-06.bpo-35952.3uNuyo.rst new file mode 100644 index 000000000000..9aeea90d8162 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-29-11-47-06.bpo-35952.3uNuyo.rst @@ -0,0 +1 @@ +Fix pythoninfo when the compiler is missing.
participants (1)
-
Victor Stinner