]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 83461 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 21:58:18 +0000 (21:58 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 21:58:18 +0000 (21:58 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r83461 | georg.brandl | 2010-08-01 23:18:52 +0200 (So, 01 Aug 2010) | 9 lines

  Merged revisions 83201 via svnmerge from
  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 ee0a049c1790fb06e436234ae35f53d3420746f9..d3301b0052e9001c3c543f58c0dc75333bf9db39 100644 (file)
@@ -594,6 +594,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 ebc2adbfa2d3b579861e2fd755317968680934c0..56f1939acde0d0fe886251b875fceb1e5ddeaa82 100644 (file)
@@ -412,6 +412,17 @@ if hasattr(asyncore, 'file_wrapper'):
             w.close()
             self.assertEqual(file(TESTFN).read(), self.d + d1 + d2)
 
+        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("".join(data), self.d)
+
 
 def test_main():
     tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests,
index 2f6055e58361decc53b40bdc9c73d52825a4997a..dd86e5c070d3291e2e7f4be791cb1c64d8e90f6e 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -407,6 +407,7 @@ Ivan Krstić
 Andrew Kuchling
 Vladimir Kushnir
 Cameron Laird
+Łukasz Langa
 Tino Lange
 Andrew Langmead
 Detlef Lannert
index 2f25dcb7228b7a342f9c52306b61a6a315b44cf3..b0e66a39b268396076149f249be864f4669b8693 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,8 @@ Core and Builtins
   when turned into an exception: in this case the exception simply
   gets ignored.
 
+- Issue #9354: Provide getsockopt() in asyncore's file_wrapper.
+
 - In the unicode/str.format(), raise a ValueError when indexes to arguments are
   too large.