From a0b22d22038fd9d858a8bcdf64e5f67d016e4555 Mon Sep 17 00:00:00 2001 From: Santiago Castro Date: Mon, 4 Jul 2022 09:50:47 -0700 Subject: [PATCH 1/3] Fix when `sys.executable` is empty or null --- src/PIL/ImageShow.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 9117f57e570..5ca8035b15b 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -178,14 +178,15 @@ def show_file(self, path=None, **options): else: raise TypeError("Missing required argument: 'path'") subprocess.call(["open", "-a", "Preview.app", path]) - subprocess.Popen( - [ - sys.executable, - "-c", - "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", - path, - ] - ) + if sys.executable: + subprocess.Popen( + [ + sys.executable, + "-c", + "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", + path, + ] + ) return 1 From 527eecae80f41965ebf6aa3847baecaa41b1158c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 5 Jul 2022 13:42:41 +1000 Subject: [PATCH 2/3] Fallback to python3 --- src/PIL/ImageShow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 5ca8035b15b..1b2b9f05fbf 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -178,10 +178,11 @@ def show_file(self, path=None, **options): else: raise TypeError("Missing required argument: 'path'") subprocess.call(["open", "-a", "Preview.app", path]) - if sys.executable: + exectable = sys.executable or shutil.which("python3") + if executable: subprocess.Popen( [ - sys.executable, + executable, "-c", "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", path, From 4f7f5470b13b4006db58f2e2396ea0f17c3de373 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 6 Jul 2022 08:30:24 +1000 Subject: [PATCH 3/3] Fixed typo --- src/PIL/ImageShow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 1b2b9f05fbf..9f9a551fb6f 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -178,7 +178,7 @@ def show_file(self, path=None, **options): else: raise TypeError("Missing required argument: 'path'") subprocess.call(["open", "-a", "Preview.app", path]) - exectable = sys.executable or shutil.which("python3") + executable = sys.executable or shutil.which("python3") if executable: subprocess.Popen( [