Skip to content

Commit 643f368

Browse files
committed
Treat ENXIO as success
1 parent e4a9a67 commit 643f368

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Lib/test/test_pyrepl/eio_test_script.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def create_eio_condition():
2121
try:
2222
os.setsid()
2323
fcntl.ioctl(slave_fd, termios.TIOCSCTTY, 0)
24-
p2_pgid = os.getpgrp()
24+
child_process_group_id = os.getpgrp()
2525
grandchild_pid = os.fork()
2626
if grandchild_pid == 0:
2727
os.setpgid(0, 0) # set process group for grandchild
@@ -33,7 +33,7 @@ def create_eio_condition():
3333
sys.exit(0) # exit the child process that was just obtained
3434
else:
3535
try:
36-
os.tcsetpgrp(0, p2_pgid)
36+
os.tcsetpgrp(0, child_process_group_id)
3737
except OSError:
3838
pass
3939
sys.exit(0)
@@ -48,7 +48,7 @@ def create_eio_condition():
4848
os.close(slave_fd)
4949
os.waitpid(grandchild_pid, 0)
5050
# Manipulate terminal control to create EIO condition
51-
os.tcsetpgrp(master_fd, p2_pgid)
51+
os.tcsetpgrp(master_fd, child_process_group_id)
5252
# Now try to read from master - this might cause EIO
5353
try:
5454
os.read(master_fd, 1)

Lib/test/test_pyrepl/test_unix_console.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def test_restore_with_invalid_environ_on_macos(self, _os_write):
318318
console.restore() # this should succeed
319319

320320

321+
@unittest.skipIf(sys.platform == "win32", "No Unix console on Windows")
321322
class TestUnixConsoleEIOHandling(TestCase):
322323

323324
@patch('_pyrepl.unix_console.tcsetattr')
@@ -359,5 +360,15 @@ def test_repl_eio(self):
359360

360361
os.kill(proc.pid, signal.SIGUSR1)
361362
_, err = proc.communicate(timeout=5) # sleep for pty to settle
362-
self.assertEqual(proc.returncode, 1, f"Expected EIO error, got return code {proc.returncode}")
363-
self.assertIn("Got EIO:", err, f"Expected EIO error message in stderr: {err}")
363+
self.assertEqual(
364+
proc.returncode,
365+
1,
366+
f"Expected EIO/ENXIO error, got return code {proc.returncode}",
367+
)
368+
self.assertTrue(
369+
(
370+
"Got EIO:" in err
371+
or "Got ENXIO:" in err
372+
),
373+
f"Expected EIO/ENXIO error message in stderr: {err}",
374+
)

0 commit comments

Comments
 (0)