Commit 7410402
1 parent 067df2b commit 7410402
File tree
2 files changed
+20
-2
lines changed- Lib/test
2 files changed
+20-2lines changedLines changed: 10 additions & 1 deletionOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@1111cpython_only, get_pagesize, is_apple, requires_subprocess, verbose1212)1313from test.support.import_helper import import_module14-from test.support.os_helper import TESTFN, unlink14+from test.support.os_helper import TESTFN, unlink, make_bad_fd151516161717# Skip test if no fcntl module.@@ -228,6 +228,15 @@ def test_fcntl_f_pipesize(self):228228os.close(test_pipe_r)229229os.close(test_pipe_w)230230231+@unittest.skipUnless(hasattr(fcntl, 'F_DUPFD'), 'need fcntl.F_DUPFD')232+def test_bad_fd(self):233+# gh-134744: Test error handling234+fd = make_bad_fd()235+with self.assertRaises(OSError):236+fcntl.fcntl(fd, fcntl.F_DUPFD, 0)237+with self.assertRaises(OSError):238+fcntl.fcntl(fd, fcntl.F_DUPFD, b'\0' * 1024)239+231240232241if __name__ == '__main__':233242unittest.main()Lines changed: 10 additions & 1 deletionOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@55import threading66import unittest77from test import support8-from test.support import threading_helper8+from test.support import os_helper, threading_helper99from test.support.import_helper import import_module1010fcntl = import_module('fcntl')1111termios = import_module('termios')@@ -208,6 +208,15 @@ def test_ioctl_signed_unsigned_code_param(self):208208new_winsz = fcntl.ioctl(self.master_fd, set_winsz_opcode_pos, our_winsz)209209new_winsz = fcntl.ioctl(self.master_fd, set_winsz_opcode_maybe_neg, our_winsz)210210211+@unittest.skipUnless(hasattr(fcntl, 'FICLONE'), 'need fcntl.FICLONE')212+def test_bad_fd(self):213+# gh-134744: Test error handling214+fd = os_helper.make_bad_fd()215+with self.assertRaises(OSError):216+fcntl.ioctl(fd, fcntl.FICLONE, fd)217+with self.assertRaises(OSError):218+fcntl.ioctl(fd, fcntl.FICLONE, b'\0' * 1024)219+211220212221if __name__ == "__main__":213222unittest.main()
0 commit comments