From d956f6dcff53ce6095e2ae9cfb1b185fc945213c Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Sat, 18 Apr 2020 09:09:13 +0800 Subject: [PATCH] bpo-35967: Ignore errors from `uname -p` in test_uname_processor on Android The uname binary on Android does not support -p [1]. Here is a sample log: 0:06:03 load avg: 0.56 [254/421/8] test_platform failed -- running: test_asyncio (5 min 53 sec) uname: Unknown option p (see "uname --help") test test_platform failed -- Traceback (most recent call last): File "/data/local/tmp/lib/python3.9/test/test_platform.py", line 170, in test_uname_processor proc_res = subprocess.check_output(['uname', '-p'], text=True).strip() File "/data/local/tmp/lib/python3.9/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/data/local/tmp/lib/python3.9/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['uname', '-p']' returned non-zero exit status 1. [1] https://android.googlesource.com/platform/external/toybox/+/refs/heads/master/toys/posix/uname.c --- Lib/test/test_platform.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 855304a68c2040..998f1e0dc315ab 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -167,8 +167,11 @@ def test_uname_processor(self): On some systems, the processor must match the output of 'uname -p'. See Issue 35967 for rationale. """ - proc_res = subprocess.check_output(['uname', '-p'], text=True).strip() - expect = platform._unknown_as_blank(proc_res) + try: + proc_res = subprocess.check_output(['uname', '-p'], text=True).strip() + expect = platform._unknown_as_blank(proc_res) + except (OSError, subprocess.CalledProcessError): + expect = '' self.assertEqual(platform.uname().processor, expect) @unittest.skipUnless(sys.platform.startswith('win'), "windows only test")