summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-10-18 11:39:34 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-10-18 11:39:34 (GMT)
commiteee80ee2efa5288b3e30d3336a9fce0ebdde68eb (patch)
tree9676bba14ad67a06727a4d46bbd6b8de324c2e20
parent61c5edf6fc9a87089c85f5a53e91e99da51ba38c (diff)
downloadcpython-eee80ee2efa5288b3e30d3336a9fce0ebdde68eb.zip
cpython-eee80ee2efa5288b3e30d3336a9fce0ebdde68eb.tar.gz
cpython-eee80ee2efa5288b3e30d3336a9fce0ebdde68eb.tar.bz2
Patch #470744: Simplify __repr__ error handling.
-rw-r--r--Lib/asyncore.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 84f8a11..5225d4b 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -50,7 +50,6 @@ import exceptions
import select
import socket
import sys
-import types
import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
@@ -208,28 +207,17 @@ class dispatcher:
self.addr = sock.getpeername()
def __repr__ (self):
- try:
status = [self.__class__.__module__+"."+self.__class__.__name__]
if self.accepting and self.addr:
status.append ('listening')
elif self.connected:
status.append ('connected')
- if self.addr:
- if type(self.addr) == types.TupleType:
+ if self.addr is not None:
+ try:
status.append ('%s:%d' % self.addr)
- else:
- status.append (self.addr)
+ except TypeError:
+ status.append (repr(self.addr))
return '<%s at %#x>' % (' '.join (status), id (self))
- except:
- pass
-
- try:
- ar = repr (self.addr)
- except AttributeError:
- ar = 'no self.addr!'
-
- 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)