[Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.22,1.23

Martin v. L?wis loewis@users.sourceforge.net
Thu, 18 Oct 2001 04:39:36 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv23907

Modified Files:
	asyncore.py 
Log Message:
Patch #470744: Simplify __repr__ error handling.


Index: asyncore.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** asyncore.py	2001/10/12 22:39:20	1.22
--- asyncore.py	2001/10/18 11:39:34	1.23
***************
*** 51,55 ****
  import socket
  import sys
- import types
  
  import os
--- 51,54 ----
***************
*** 209,213 ****
  
      def __repr__ (self):
-         try:
              status = [self.__class__.__module__+"."+self.__class__.__name__]
              if self.accepting and self.addr:
--- 208,211 ----
***************
*** 215,234 ****
              elif self.connected:
                  status.append ('connected')
!             if self.addr:
!                 if type(self.addr) == types.TupleType:
                      status.append ('%s:%d' % self.addr)
!                 else:
!                     status.append (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):
--- 213,222 ----
              elif self.connected:
                  status.append ('connected')
!             if self.addr is not None:
!                 try:
                      status.append ('%s:%d' % self.addr)
!                 except TypeError:
!                     status.append (repr(self.addr))
              return '<%s at %#x>' % (' '.join (status), id (self))
  
      def add_channel (self, map=None):