]> granicus.if.org Git - python/commitdiff
Merged revisions 83201 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 21:18:52 +0000 (21:18 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 21:18:52 +0000 (21:18 +0000)
svn+ssh://pythondev@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.
........

Lib/asyncore.py
Lib/test/test_asyncore.py
Misc/ACKS
Misc/NEWS

index 3e3907eee860b30639d9bd51bb87c87bef84a2bc..c23c8aa3fe4aa614b44eb216c23e66724728321f 100644 (file)
@@ -607,6 +607,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
 
index c352c396b6e65d4beb58db95febf63bc9707a60b..621733402994a7accef1a7e5968d1514777ea209 100644 (file)
@@ -428,6 +428,19 @@ class FileWrapperTest(unittest.TestCase):
         w.close()
         self.assertEqual(file(TESTFN).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):
 
index c75fced81e72e52707430b9fa1cfa01814f79b77..08b26c8c9a975508a1b7b6d5b87f20e8d4bd8aea 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -438,8 +438,8 @@ Ivan Krstić
 Andrew Kuchling
 Vladimir Kushnir
 Cameron Laird
-Tino Lange
 Łukasz Langa
+Tino Lange
 Andrew Langmead
 Detlef Lannert
 Soren Larsen
index 175e11711b91fc23d5021cece03e1910a82c0494..29b777a008bfc975466cc5457fd39ef4a4ba3ebf 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #9354: Provide getsockopt() in asyncore's file_wrapper.
+
 - Issue #4108: In urllib.robotparser, if there are multiple 'User-agent: *'
   entries, consider the first one.
 
@@ -951,6 +953,7 @@ Core and Builtins
 
 Library
 -------
+
 - Issue #1555570: email no longer inserts extra blank lines when a \r\n
   combo crosses an 8192 byte boundary.