Message306934
| Author |
martin.panter |
| Recipients |
Cornelius Diekmann, chris.torek, jbeck, martin.panter, vstinner |
| Date |
2017年11月25日.02:13:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1511576010.47.0.213398074469.issue26228@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
If it helps, here is a basic test case I wrote for "pty.spawn". I hope that it exposes the problem on Free BSD, but I have only tested it on Linux.
parent = r'''\
import pty, sys
pty.spawn((sys.executable, "-c", sys.argv[1]))
'''
child = r'''\
import sys
# Read input first of all to minimize output buffering
input = sys.stdin.readline()
print("isatty: {}, {}, {}".format(
sys.stdin.isatty(), sys.stdout.isatty(), sys.stderr.isatty()))
print("input: " + repr(input))
sys.stdout.write("stdout data\n")
sys.stderr.write("stderr data\n")
'''
args = (sys.executable, "-c", parent, child)
parent = subprocess.Popen(args,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
parent.stdin.write(b"stdin data\n")
parent.stdin.flush()
# Leave input open. When the child closes the slave terminal on
# Free BSD, "spawn" used to keep waiting for input (BPO 26228).
output = parent.stdout.read()
finally:
parent.stdout.close()
parent.stdin.close()
parent.wait()
self.assertEqual(0, parent.returncode, repr(output))
self.assertIn(b"isatty: True, True, True", output)
self.assertIn(br"input: 'stdin data\n'", output)
self.assertIn(b"stdout data", output)
self.assertIn(b"stderr data", output) |
|