summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/spawn.py
diff options
context:
space:
mode:
authorGéry Ogam <gery.ogam@gmail.com>2022-04-22 22:47:09 (GMT)
committerGitHub <noreply@github.com>2022-04-22 22:47:09 (GMT)
commit5576ddbbbc9c1d7a7819abc961e5d604ae0f7dd7 (patch)
tree4f87033ff66e48c11420b27c687ded28df53cd50 /Lib/multiprocessing/spawn.py
parentf912cc0e413f667a8cc257a41775272bc641b0d8 (diff)
downloadcpython-5576ddbbbc9c1d7a7819abc961e5d604ae0f7dd7.zip
cpython-5576ddbbbc9c1d7a7819abc961e5d604ae0f7dd7.tar.gz
cpython-5576ddbbbc9c1d7a7819abc961e5d604ae0f7dd7.tar.bz2
bpo-46720: Add support for path-like objects to multiprocessing.set_executable for Windows (GH-31279)
This bring the API to be on a par with Unix-like systems.
Diffstat (limited to 'Lib/multiprocessing/spawn.py')
-rw-r--r--Lib/multiprocessing/spawn.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py
index 7cc129e..09f8a22 100644
--- a/Lib/multiprocessing/spawn.py
+++ b/Lib/multiprocessing/spawn.py
@@ -33,18 +33,21 @@ else:
WINEXE = getattr(sys, 'frozen', False)
WINSERVICE = sys.executable.lower().endswith("pythonservice.exe")
-if WINSERVICE:
- _python_exe = os.path.join(sys.exec_prefix, 'python.exe')
-else:
- _python_exe = sys.executable
-
def set_executable(exe):
global _python_exe
- _python_exe = exe
+ if sys.platform == 'win32':
+ _python_exe = os.fsdecode(exe)
+ else:
+ _python_exe = os.fsencode(exe)
def get_executable():
return _python_exe
+if WINSERVICE:
+ set_executable(os.path.join(sys.exec_prefix, 'python.exe'))
+else:
+ set_executable(sys.executable)
+
#
#
#
@@ -86,7 +89,8 @@ def get_command_line(**kwds):
prog = 'from multiprocessing.spawn import spawn_main; spawn_main(%s)'
prog %= ', '.join('%s=%r' % item for item in kwds.items())
opts = util._args_from_interpreter_flags()
- return [_python_exe] + opts + ['-c', prog, '--multiprocessing-fork']
+ exe = get_executable()
+ return [exe] + opts + ['-c', prog, '--multiprocessing-fork']
def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):