mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Patch #470744: Simplify __repr__ error handling.
This commit is contained in:
parent
61c5edf6fc
commit
eee80ee2ef
1 changed files with 4 additions and 16 deletions
|
@ -50,7 +50,6 @@ import exceptions
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import types
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
|
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
|
||||||
|
@ -208,28 +207,17 @@ class dispatcher:
|
||||||
self.addr = sock.getpeername()
|
self.addr = sock.getpeername()
|
||||||
|
|
||||||
def __repr__ (self):
|
def __repr__ (self):
|
||||||
try:
|
|
||||||
status = [self.__class__.__module__+"."+self.__class__.__name__]
|
status = [self.__class__.__module__+"."+self.__class__.__name__]
|
||||||
if self.accepting and self.addr:
|
if self.accepting and self.addr:
|
||||||
status.append ('listening')
|
status.append ('listening')
|
||||||
elif self.connected:
|
elif self.connected:
|
||||||
status.append ('connected')
|
status.append ('connected')
|
||||||
if self.addr:
|
if self.addr is not None:
|
||||||
if type(self.addr) == types.TupleType:
|
try:
|
||||||
status.append ('%s:%d' % self.addr)
|
status.append ('%s:%d' % self.addr)
|
||||||
else:
|
except TypeError:
|
||||||
status.append (self.addr)
|
status.append (repr(self.addr))
|
||||||
return '<%s at %#x>' % (' '.join (status), id (self))
|
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):
|
def add_channel (self, map=None):
|
||||||
#self.log_info ('adding channel %s' % self)
|
#self.log_info ('adding channel %s' % self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue