diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-12-14 16:15:11 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-12-14 16:15:11 (GMT) |
commit | 2a05bc72d61377772ed988507bd67961bcbf35a0 (patch) | |
tree | 64302c77803d821592ba89cbb6ac16efcc91d48b /Lib/asyncore.py | |
parent | 81feb6c201f0be1d08a40e5638d4dd215e0bbe6b (diff) | |
download | cpython-2a05bc72d61377772ed988507bd67961bcbf35a0.zip cpython-2a05bc72d61377772ed988507bd67961bcbf35a0.tar.gz cpython-2a05bc72d61377772ed988507bd67961bcbf35a0.tar.bz2 |
Partial fix for problem in SF buf #487458
Rev 1.20 introduced a call to getpeername() in the dispatcher
constructor. This only works for a connected socket. Apparently
earlier versions of the code worked with un-connected sockets, e.g. a
listening socket.
It's not clear that the code is supposed to accept these sockets,
because it sets self.connected = 1 when passed a socket. But it's
also not clear that it should be a fatal error to pass a listening
socket.
The solution, for now, is to put a try/except around the getpeername()
call and continue if it fails. The self.addr attribute is used
primarily (only?) to produce a nice repr for the object, so it hardly
matters. If there is a real error on a connected socket, it's likely
that subsequent calls will fail too.
Diffstat (limited to 'Lib/asyncore.py')
-rw-r--r-- | Lib/asyncore.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index 5740fe1..e79593a 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -212,7 +212,13 @@ class dispatcher: # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 - self.addr = sock.getpeername() + # XXX Does the constructor require that the socket passed + # be connected? + try: + self.addr = sock.getpeername() + except socket.error: + # The addr isn't crucial + pass else: self.socket = None |