Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21afd01

Browse files
author
Nicholas Riley
committed
Change for Python 1.6 compatibility - UNIX's 'os' module defines
'spawnv' now, so we check for 'fork' first.
1 parent 1f54902 commit 21afd01

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

Lib/idlelib/spawn.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,7 @@ def hardpath(path):
1313
pass
1414
return path
1515

16-
if hasattr(os, 'spawnv'):
17-
18-
# Windows-ish OS: we use spawnv(), and stick quotes around arguments
19-
# in case they contains spaces, since Windows will jam all the
20-
# arguments to spawn() or exec() together into one string. The
21-
# kill_zombies function is a noop.
22-
23-
def spawn(bin, *args):
24-
nargs = [bin]
25-
for arg in args:
26-
nargs.append( '"'+arg+'"' )
27-
os.spawnv( os.P_NOWAIT, bin, nargs )
28-
29-
def kill_zombies(): pass
30-
31-
elif hasattr(os, 'fork'):
16+
if hasattr(os, 'fork'):
3217

3318
# UNIX-ish operating system: we fork() and exec(), and we have to track
3419
# the pids of our children and call waitpid() on them to avoid leaving
@@ -49,6 +34,20 @@ def kill_zombies():
4934
stat = os.waitpid(z, os.WNOHANG)
5035
if stat[0]==z:
5136
zombies.remove(z)
37+
elif hasattr(os, 'spawnv'):
38+
39+
# Windows-ish OS: we use spawnv(), and stick quotes around arguments
40+
# in case they contains spaces, since Windows will jam all the
41+
# arguments to spawn() or exec() together into one string. The
42+
# kill_zombies function is a noop.
43+
44+
def spawn(bin, *args):
45+
nargs = [bin]
46+
for arg in args:
47+
nargs.append( '"'+arg+'"' )
48+
os.spawnv( os.P_NOWAIT, bin, nargs )
49+
50+
def kill_zombies(): pass
5251

5352
else:
5453
# If you get here, you may be able to write an alternative implementation

0 commit comments

Comments
 (0)