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.
........
This commit is contained in:
Georg Brandl 2010-08-01 21:18:52 +00:00
parent f89972b3da
commit 7f0c3ffad5
4 changed files with 25 additions and 1 deletions

View File

@ -607,6 +607,14 @@ if os.name == 'posix':
def send(self, *args): def send(self, *args):
return os.write(self.fd, *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 read = recv
write = send write = send

View File

@ -428,6 +428,19 @@ class FileWrapperTest(unittest.TestCase):
w.close() w.close()
self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) 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): class BaseTestHandler(asyncore.dispatcher):

View File

@ -438,8 +438,8 @@ Ivan Krstić
Andrew Kuchling Andrew Kuchling
Vladimir Kushnir Vladimir Kushnir
Cameron Laird Cameron Laird
Tino Lange
Łukasz Langa Łukasz Langa
Tino Lange
Andrew Langmead Andrew Langmead
Detlef Lannert Detlef Lannert
Soren Larsen Soren Larsen

View File

@ -24,6 +24,8 @@ Core and Builtins
Library Library
------- -------
- Issue #9354: Provide getsockopt() in asyncore's file_wrapper.
- Issue #4108: In urllib.robotparser, if there are multiple 'User-agent: *' - Issue #4108: In urllib.robotparser, if there are multiple 'User-agent: *'
entries, consider the first one. entries, consider the first one.
@ -951,6 +953,7 @@ Core and Builtins
Library Library
------- -------
- Issue #1555570: email no longer inserts extra blank lines when a \r\n - Issue #1555570: email no longer inserts extra blank lines when a \r\n
combo crosses an 8192 byte boundary. combo crosses an 8192 byte boundary.