[Python-checkins] r83460 - in python/branches/release31-maint: Lib/asyncore.py Lib/test/test_asyncore.py Misc/ACKS Misc/NEWS

georg.brandl python-checkins at python.org
Sun Aug 1 23:16:54 CEST 2010


Author: georg.brandl
Date: Sun Aug  1 23:16:54 2010
New Revision: 83460

Log:
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.
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/asyncore.py
   python/branches/release31-maint/Lib/test/test_asyncore.py
   python/branches/release31-maint/Misc/ACKS
   python/branches/release31-maint/Misc/NEWS

Modified: python/branches/release31-maint/Lib/asyncore.py
==============================================================================
--- python/branches/release31-maint/Lib/asyncore.py	(original)
+++ python/branches/release31-maint/Lib/asyncore.py	Sun Aug  1 23:16:54 2010
@@ -598,6 +598,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/release31-maint/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_asyncore.py	(original)
+++ python/branches/release31-maint/Lib/test/test_asyncore.py	Sun Aug  1 23:16:54 2010
@@ -413,6 +413,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)
+
 
 def test_main():
     tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests,

Modified: python/branches/release31-maint/Misc/ACKS
==============================================================================
--- python/branches/release31-maint/Misc/ACKS	(original)
+++ python/branches/release31-maint/Misc/ACKS	Sun Aug  1 23:16:54 2010
@@ -426,6 +426,7 @@
 Andrew Kuchling
 Vladimir Kushnir
 Cameron Laird
+Łukasz Langa
 Tino Lange
 Andrew Langmead
 Detlef Lannert

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Sun Aug  1 23:16:54 2010
@@ -127,6 +127,8 @@
 
 - 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.
 


More information about the Python-checkins mailing list