aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 1ee3acd7076..c838e95ad55 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -752,6 +752,20 @@ class CmdLineTest(unittest.TestCase):
self.assertIn(": can't open file ", err)
self.assertNotEqual(proc.returncode, 0)
+ @unittest.skipUnless(os.path.exists('/dev/fd/0'), 'requires /dev/fd platform')
+ def test_script_as_dev_fd(self):
+ # GH-87235: On macOS passing a non-trivial script to /dev/fd/N can cause
+ # problems because all open /dev/fd/N file descriptors share the same
+ # offset.
+ script = 'print("12345678912345678912345")'
+ with os_helper.temp_dir() as work_dir:
+ script_name = _make_test_script(work_dir, 'script.py', script)
+ with open(script_name, "r") as fp:
+ p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=False, pass_fds=(0,1,2,fp.fileno()))
+ out, err = p.communicate()
+ self.assertEqual(out, b"12345678912345678912345\n")
+
+
def tearDownModule():
support.reap_children()