cpython: 42cf963e3ab1 (original) (raw)
Mercurial > cpython
changeset 91745:42cf963e3ab1
Issue #22018: signal.set_wakeup_fd() now raises an OSError instead of a ValueError on fstat() failure. [#22018]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Mon, 21 Jul 2014 16:28:54 +0200 |
parents | 057a8bd043ea |
children | 7a1737033a23 |
files | Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c |
diffstat | 3 files changed, 17 insertions(+), 6 deletions(-)[+] [-] Lib/test/test_signal.py 6 Misc/NEWS 3 Modules/signalmodule.c 14 |
line wrap: on
line diff
--- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -252,14 +252,14 @@ class WakeupFDTests(unittest.TestCase): def test_invalid_fd(self): fd = support.make_bad_fd()
self.assertRaises(ValueError, signal.set_wakeup_fd, fd)[](#l1.7)
self.assertRaises(OSError, signal.set_wakeup_fd, fd)[](#l1.8)
def test_set_wakeup_fd_result(self): r1, w1 = os.pipe()
os.close(r1)[](#l1.12)
self.addCleanup(os.close, r1)[](#l1.13) self.addCleanup(os.close, w1)[](#l1.14) r2, w2 = os.pipe()[](#l1.15)
os.close(r2)[](#l1.16)
self.addCleanup(os.close, r2)[](#l1.17) self.addCleanup(os.close, w2)[](#l1.18)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -108,6 +108,9 @@ Core and Builtins Library ------- +- Issue #22018: signal.set_wakeup_fd() now raises an OSError instead of a
- Issue #21044: tarfile.open() now handles fileobj with an integer 'name' attribute. Based on patch by Martin Panter.
--- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -437,12 +437,20 @@ signal_set_wakeup_fd(PyObject *self, PyO return NULL; } #endif
- if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) {
PyErr_SetString(PyExc_ValueError, "invalid fd");[](#l3.8)
return NULL;[](#l3.9)