[Python-checkins] r83201 - in python/branches/py3k: Lib/asyncore.py Lib/test/test_asyncore.py Misc/ACKS Misc/NEWS

georg.brandl python-checkins at python.org
Wed Jul 28 10:19:37 CEST 2010


Author: georg.brandl
Date: Wed Jul 28 10:19:35 2010
New Revision: 83201

Log:
#9354: Provide getsockopt() in asyncore file_wrapper().  Patch by Lukas Langa.

Modified:
   python/branches/py3k/Lib/asyncore.py
   python/branches/py3k/Lib/test/test_asyncore.py
   python/branches/py3k/Misc/ACKS
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/asyncore.py
==============================================================================
--- python/branches/py3k/Lib/asyncore.py	(original)
+++ python/branches/py3k/Lib/asyncore.py	Wed Jul 28 10:19:35 2010
@@ -607,6 +607,14 @@
         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
 

Modified: python/branches/py3k/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k/Lib/test/test_asyncore.py	Wed Jul 28 10:19:35 2010
@@ -428,6 +428,19 @@
         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)
+
 
 class BaseTestHandler(asyncore.dispatcher):
 

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Wed Jul 28 10:19:35 2010
@@ -448,8 +448,8 @@
 Vladimir Kushnir
 Cameron Laird
 Torsten Landschoff
-Tino Lange
 Łukasz Langa
+Tino Lange
 Andrew Langmead
 Detlef Lannert
 Soren Larsen

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Jul 28 10:19:35 2010
@@ -475,6 +475,8 @@
 Library
 -------
 
+- Issue #9354: Provide getsockopt() in asyncore's file_wrapper.
+
 - Issue #8966: ctypes: Remove implicit bytes-unicode conversion.
 
 - Issue #9378: python -m pickle <pickle file> will now load and


More information about the Python-checkins mailing list