diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-20 19:04:55 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-20 19:04:55 +0000 |
commit | 85512b0abedd85dec25a03f5270a8a4e24b3269d (patch) | |
tree | 6deed62ea10071db32a127e6c4e0518db6f64d02 /Lib | |
parent | c9b5ab58590482513819459d80352e02fda46ce7 (diff) | |
download | cpython-85512b0abedd85dec25a03f5270a8a4e24b3269d.tar.gz |
dispatcher.__repr__() was unprepared to handle the address for a Unix
domain socket. Fix that and make the error message for failures a
little more helpful by including the class name.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/asyncore.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index 145da58bdb..8c9ec63477 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -50,6 +50,7 @@ import exceptions import select import socket import sys +import types import os if os.name == 'nt': @@ -215,19 +216,22 @@ class dispatcher: elif self.connected: status.append ('connected') if self.addr: - status.append ('%s:%d' % self.addr) - return '<%s %s at %x>' % ( - self.__class__.__name__, - ' '.join (status), - id(self) - ) + if self.addr == types.TupleType: + status.append ('%s:%d' % self.addr) + else: + status.append (self.addr) + return '<%s %s at %x>' % (self.__class__.__name__, + ' '.join (status), id (self)) except: - try: - ar = repr(self.addr) - except: - ar = 'no self.addr!' + pass + + try: + ar = repr (self.addr) + except AttributeError: + ar = 'no self.addr!' - return '<__repr__ (self) failed for object at %x (addr=%s)>' % (id(self),ar) + return '<__repr__() failed for %s instance at %x (addr=%s)>' % \ + (self.__class__.__name__, id (self), ar) def add_channel (self, map=None): #self.log_info ('adding channel %s' % self) @@ -299,6 +303,7 @@ class dispatcher: def connect (self, address): self.connected = 0 + # XXX why not use connect_ex? try: self.socket.connect (address) except socket.error, why: |