[Python-checkins] r73078 - in python/branches/release26-maint: Doc/library/select.rst Lib/test/test_epoll.py

r.david.murray python-checkins at python.org
Sun May 31 21:29:05 CEST 2009


Author: r.david.murray
Date: Sun May 31 21:29:05 2009
New Revision: 73078
Log:
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 (2009年5月31日) | 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.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Doc/library/select.rst
 python/branches/release26-maint/Lib/test/test_epoll.py
Modified: python/branches/release26-maint/Doc/library/select.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/select.rst	(original)
+++ python/branches/release26-maint/Doc/library/select.rst	Sun May 31 21:29:05 2009
@@ -160,6 +160,11 @@
 
 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)
 
Modified: python/branches/release26-maint/Lib/test/test_epoll.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_epoll.py	(original)
+++ python/branches/release26-maint/Lib/test/test_epoll.py	Sun May 31 21:29:05 2009
@@ -95,6 +95,34 @@
 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()
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /