From 9d2336189df024a67b37607a38b9fd0621d513c1 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 30 Nov 2021 12:41:10 +0100 Subject: [PATCH 1/2] bpo-40280: Emscripten has no support for subprocesses Signed-off-by: Christian Heimes --- Lib/platform.py | 10 ++++++++-- Lib/pydoc.py | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 9e9b42238fb76c..5e2b5bab5718a4 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -607,7 +607,10 @@ def _syscmd_file(target, default=''): # XXX Others too ? return default - import subprocess + try: + import subprocess + except ImportError: + return default target = _follow_symlinks(target) # "file" output is locale dependent: force the usage of the C locale # to get deterministic behavior. @@ -746,7 +749,10 @@ def from_subprocess(): """ Fall back to `uname -p` """ - import subprocess + try: + import subprocess + except ImportError: + return try: return subprocess.check_output( ['uname', '-p'], diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 3a2ff218f8319a..7d52359c9a0ce9 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1556,6 +1556,8 @@ def getpager(): return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager + if sys.platform == "emscripten": + return plainpager use_pager = os.environ.get('MANPAGER') or os.environ.get('PAGER') if use_pager: if sys.platform == 'win32': # pipes completely broken in Windows From 852b20197b356c3d5392b67e888b290b9da5d0d4 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 2 Dec 2021 10:19:32 +0200 Subject: [PATCH 2/2] return None Co-authored-by: Brett Cannon --- Lib/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 5e2b5bab5718a4..3f3f25a2c92d3b 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -752,7 +752,7 @@ def from_subprocess(): try: import subprocess except ImportError: - return + return None try: return subprocess.check_output( ['uname', '-p'],