mirror of
https://github.com/python/cpython.git
synced 2025-09-05 00:11:10 +00:00
check windows fd validity (closes #16992)
This commit is contained in:
parent
fc4aa76d59
commit
c68a4a048c
3 changed files with 13 additions and 3 deletions
|
@ -222,6 +222,13 @@ class WindowsSignalTests(unittest.TestCase):
|
||||||
signal.signal(7, handler)
|
signal.signal(7, handler)
|
||||||
|
|
||||||
|
|
||||||
|
class WakeupFDTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_invalid_fd(self):
|
||||||
|
fd = support.make_bad_fd()
|
||||||
|
self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
||||||
class WakeupSignalTests(unittest.TestCase):
|
class WakeupSignalTests(unittest.TestCase):
|
||||||
def check_wakeup(self, test_body, *signals, ordered=True):
|
def check_wakeup(self, test_body, *signals, ordered=True):
|
||||||
|
@ -864,8 +871,8 @@ class PendingSignalsTests(unittest.TestCase):
|
||||||
def test_main():
|
def test_main():
|
||||||
try:
|
try:
|
||||||
support.run_unittest(PosixTests, InterProcessSignalTests,
|
support.run_unittest(PosixTests, InterProcessSignalTests,
|
||||||
WakeupSignalTests, SiginterruptTest,
|
WakeupFDTests, WakeupSignalTests,
|
||||||
ItimerTest, WindowsSignalTests,
|
SiginterruptTest, ItimerTest, WindowsSignalTests,
|
||||||
PendingSignalsTests)
|
PendingSignalsTests)
|
||||||
finally:
|
finally:
|
||||||
support.reap_children()
|
support.reap_children()
|
||||||
|
|
|
@ -150,6 +150,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file
|
||||||
|
descriptor argument.
|
||||||
|
|
||||||
- Issue #16422: For compatibility with the Python version, the C version of
|
- Issue #16422: For compatibility with the Python version, the C version of
|
||||||
decimal now uses strings instead of integers for rounding mode constants.
|
decimal now uses strings instead of integers for rounding mode constants.
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (fd != -1 && fstat(fd, &buf) != 0) {
|
if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "invalid fd");
|
PyErr_SetString(PyExc_ValueError, "invalid fd");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue