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

Skip to content

Commit 0c44c04

Browse files
committed
sys.executable can contain spaces, cater for this when passing it to
os.popen(). Fixes #692222.
1 parent 9ce623f commit 0c44c04

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/test/test_atexit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def handler2(*args, **kargs):
2727
f.write(input)
2828
f.close()
2929

30-
p = popen("%s %s" % (executable, fname))
30+
p = popen('"%s" %s' % (executable, fname))
3131
output = p.read()
3232
p.close()
3333
vereq(output, """\
@@ -55,7 +55,7 @@ def indirect():
5555
f.write(input)
5656
f.close()
5757

58-
p = popen("%s %s" % (executable, fname))
58+
p = popen('"%s" %s' % (executable, fname))
5959
output = p.read()
6060
p.close()
6161
vereq(output, """\

Lib/test/test_popen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# This results in Python being spawned and printing the sys.argv list.
1616
# We can then eval() the result of this, and see what each argv was.
1717
def _do_test_commandline(cmdline, expected):
18-
cmd = '%s -c "import sys;print sys.argv" %s' % (sys.executable, cmdline)
18+
cmd = '"%s" -c "import sys;print sys.argv" %s' % (sys.executable, cmdline)
1919
data = popen(cmd).read()
2020
got = eval(data)[1:] # strip off argv[0]
2121
if got != expected:

0 commit comments

Comments
 (0)