diff options
author | Jesus Cea <jcea@jcea.es> | 2011-09-21 01:47:39 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2011-09-21 01:47:39 (GMT) |
commit | c23484b21f8b62ec7c62a6e2253cf5f656e2ef06 (patch) | |
tree | 6ae29d5fec5ac44b18f218c9de2da19ad4b2d24d /Lib | |
parent | 4ac5d2cda495b90c7990f9e231553fa2dca9854f (diff) | |
download | cpython-c23484b21f8b62ec7c62a6e2253cf5f656e2ef06.zip cpython-c23484b21f8b62ec7c62a6e2253cf5f656e2ef06.tar.gz cpython-c23484b21f8b62ec7c62a6e2253cf5f656e2ef06.tar.bz2 |
Close #13022: _multiprocessing.recvfd() doesn't check that file descriptor was actually received
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_multiprocessing.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index c2a2f19..0e480a9 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1574,6 +1574,23 @@ class _TestConnection(BaseTestCase): with open(test_support.TESTFN, "rb") as f: self.assertEqual(f.read(), b"bar") + @classmethod + def _send_data_without_fd(self, conn): + os.write(conn.fileno(), b"\0") + + @unittest.skipIf(sys.platform == "win32", "doesn't make sense on Windows") + def test_missing_fd_transfer(self): + # Check that exception is raised when received data is not + # accompanied by a file descriptor in ancillary data. + if self.TYPE != 'processes': + self.skipTest("only makes sense with processes") + conn, child_conn = self.Pipe(duplex=True) + + p = self.Process(target=self._send_data_without_fd, args=(child_conn,)) + p.daemon = True + p.start() + self.assertRaises(RuntimeError, reduction.recv_handle, conn) + p.join() class _TestListenerClient(BaseTestCase): |