diff options
author | Georg Brandl <georg@python.org> | 2010-08-01 21:16:54 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-08-01 21:16:54 (GMT) |
commit | bd9c6d097ec98661adfd337b1a9ded640bc28c8e (patch) | |
tree | f2c9c14479c4608d6622a09976c522f5e3c910b1 | |
parent | 77925b067d2654f852d027f2d23760d639dd9422 (diff) | |
download | cpython-bd9c6d097ec98661adfd337b1a9ded640bc28c8e.zip cpython-bd9c6d097ec98661adfd337b1a9ded640bc28c8e.tar.gz cpython-bd9c6d097ec98661adfd337b1a9ded640bc28c8e.tar.bz2 |
Merged revisions 83201 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r83201 | georg.brandl | 2010-07-28 10:19:35 +0200 (Mi, 28 Jul 2010) | 1 line
#9354: Provide getsockopt() in asyncore file_wrapper(). Patch by Lukas Langa.
........
-rw-r--r-- | Lib/asyncore.py | 8 | ||||
-rw-r--r-- | Lib/test/test_asyncore.py | 13 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
4 files changed, 24 insertions, 0 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index 44e8918..f066e76 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -598,6 +598,14 @@ if os.name == 'posix': def send(self, *args): return os.write(self.fd, *args) + def getsockopt(self, level, optname, buflen=None): + if (level == socket.SOL_SOCKET and + optname == socket.SO_ERROR and + not buflen): + return 0 + raise NotImplementedError("Only asyncore specific behaviour " + "implemented.") + read = recv write = send diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 785b211..c82f9b7 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -413,6 +413,19 @@ if hasattr(asyncore, 'file_wrapper'): w.close() self.assertEqual(open(TESTFN, 'rb').read(), self.d + d1 + d2) + @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'), + ' asyncore.file_dispatcher required') + def test_dispatcher(self): + fd = os.open(TESTFN, os.O_RDONLY) + data = [] + class FileDispatcher(asyncore.file_dispatcher): + def handle_read(self): + data.append(self.recv(29)) + s = FileDispatcher(fd) + os.close(fd) + asyncore.loop(timeout=0.01, use_poll=True, count=2) + self.assertEqual(b"".join(data), self.d) + def test_main(): tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, @@ -426,6 +426,7 @@ Hannu Krosing Andrew Kuchling Vladimir Kushnir Cameron Laird +Ćukasz Langa Tino Lange Andrew Langmead Detlef Lannert @@ -127,6 +127,8 @@ Library - Issue #1690103: Fix initial namespace for code run with trace.main(). +- Issue #9354: Provide getsockopt() in asyncore's file_wrapper. + - Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when re-initializing a buffered IO object by calling its ``__init__`` method. |