Skip to content

Commit 6477c7e

Browse files
committed
pythongh-90522: add test
Subprocess opening /dev/stdin fails if it is a socketpair.
1 parent 97b4121 commit 6477c7e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,26 @@ async def empty_error():
402402
self.assertEqual(output, None)
403403
self.assertEqual(exitcode, 0)
404404

405+
@unittest.skipIf(sys.platform != 'linux', "Don't have /dev/stdin")
406+
def test_devstdin_input(self):
407+
408+
async def devstdin_input(message):
409+
code = 'file = open("/dev/stdin"); data = file.read(); print(len(data))'
410+
proc = await asyncio.create_subprocess_exec(
411+
sys.executable, '-c', code,
412+
stdin=asyncio.subprocess.PIPE,
413+
stdout=asyncio.subprocess.PIPE,
414+
stderr=asyncio.subprocess.PIPE,
415+
close_fds=False,
416+
)
417+
stdout, stderr = await proc.communicate(message)
418+
exitcode = await proc.wait()
419+
return (stdout, exitcode)
420+
421+
output, exitcode = self.loop.run_until_complete(devstdin_input(b'abc'))
422+
self.assertEqual(output.rstrip(), b'3')
423+
self.assertEqual(exitcode, 0)
424+
405425
def test_cancel_process_wait(self):
406426
# Issue #23140: cancel Process.wait()
407427

0 commit comments

Comments
 (0)