summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-05-31 19:29:05 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-05-31 19:29:05 (GMT)
commite6a4d78a62ea83de2e08d71472c6e7fdfb2705bf (patch)
tree707a1708f95a4172241110e7f26833c5b0ddf246
parent6987d541160ae69f896d0344f47230cbb12914e4 (diff)
downloadcpython-e6a4d78a62ea83de2e08d71472c6e7fdfb2705bf.zip
cpython-e6a4d78a62ea83de2e08d71472c6e7fdfb2705bf.tar.gz
cpython-e6a4d78a62ea83de2e08d71472c6e7fdfb2705bf.tar.bz2
Merged revisions 73077 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r73077 | r.david.murray | 2009-05-31 15:15:57 -0400 (Sun, 31 May 2009) | 4 lines Issue 3848: document the fact that epoll register raises an IOError if an fd is registered twice, and add some additional epoll tests. Patch by Christian Heimes. ........
-rw-r--r--Doc/library/select.rst5
-rw-r--r--Lib/test/test_epoll.py28
2 files changed, 33 insertions, 0 deletions
diff --git a/Doc/library/select.rst b/Doc/library/select.rst
index 1300f23..351ecfa 100644
--- a/Doc/library/select.rst
+++ b/Doc/library/select.rst
@@ -160,6 +160,11 @@ Edge and Level Trigger Polling (epoll) Objects
Register a fd descriptor with the epoll object.
+ .. note::
+
+ Registering a file descriptor that's already registered raises an
+ IOError -- contrary to :ref:`poll-objects`'s register.
+
.. method:: epoll.modify(fd, eventmask)
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index ab1756c..aab2c6b 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -95,6 +95,34 @@ class TestEPoll(unittest.TestCase):
finally:
ep.close()
+ # adding by object w/ fileno works, too.
+ ep = select.epoll(2)
+ try:
+ ep.register(server, select.EPOLLIN | select.EPOLLOUT)
+ ep.register(client, select.EPOLLIN | select.EPOLLOUT)
+ finally:
+ ep.close()
+
+ ep = select.epoll(2)
+ try:
+ # TypeError: argument must be an int, or have a fileno() method.
+ self.assertRaises(TypeError, ep.register, object(),
+ select.EPOLLIN | select.EPOLLOUT)
+ self.assertRaises(TypeError, ep.register, None,
+ select.EPOLLIN | select.EPOLLOUT)
+ # ValueError: file descriptor cannot be a negative integer (-1)
+ self.assertRaises(ValueError, ep.register, -1,
+ select.EPOLLIN | select.EPOLLOUT)
+ # IOError: [Errno 9] Bad file descriptor
+ self.assertRaises(IOError, ep.register, 10000,
+ select.EPOLLIN | select.EPOLLOUT)
+ # registering twice also raises an exception
+ ep.register(server, select.EPOLLIN | select.EPOLLOUT)
+ self.assertRaises(IOError, ep.register, server,
+ select.EPOLLIN | select.EPOLLOUT)
+ finally:
+ ep.close()
+
def test_fromfd(self):
server, client = self._connected_pair()