Runtime: spawn_subprocess: handle non-bytes args
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 18 Jun 2023 16:30:48 +0200
changeset 3821 f7bc4e5832be
parent 3820 46f3ca3f0157
child 3822 d311880b9d15
Runtime: spawn_subprocess: handle non-bytes args
runtime/spawn_subprocess.py
--- a/runtime/spawn_subprocess.py	Sun Jun 18 16:28:42 2023 +0200
+++ b/runtime/spawn_subprocess.py	Sun Jun 18 16:30:48 2023 +0200
@@ -5,13 +5,14 @@
 
 
 
-import os
+import os, sys
 import signal
 import shlex
 import posix_spawn
 
 PIPE = "42"
 
+fsencoding = sys.getfilesystemencoding()
 
 class Popen(object):
     def __init__(self, args, stdin=None, stdout=None):
@@ -34,6 +35,7 @@
             file_actions.add_dup2(p2cread, 0)
             # close other end
             file_actions.add_close(p2cwrite)
+        args = [s.encode(fsencoding) for s in args if type(s)==str]
         self.pid = posix_spawn.posix_spawnp(args[0], args, file_actions=file_actions)
         if stdout is not None:
             self.stdout = os.fdopen(c2pread)