mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
55ad67d74d
commit
12e73bb2f0
|
@ -50,6 +50,7 @@ import exceptions
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
import types
|
||||||
|
|
||||||
import os
|
import os
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
@ -215,19 +216,22 @@ class dispatcher:
|
||||||
elif self.connected:
|
elif self.connected:
|
||||||
status.append ('connected')
|
status.append ('connected')
|
||||||
if self.addr:
|
if self.addr:
|
||||||
status.append ('%s:%d' % self.addr)
|
if self.addr == types.TupleType:
|
||||||
return '<%s %s at %x>' % (
|
status.append ('%s:%d' % self.addr)
|
||||||
self.__class__.__name__,
|
else:
|
||||||
' '.join (status),
|
status.append (self.addr)
|
||||||
id(self)
|
return '<%s %s at %x>' % (self.__class__.__name__,
|
||||||
)
|
' '.join (status), id (self))
|
||||||
except:
|
except:
|
||||||
try:
|
pass
|
||||||
ar = repr(self.addr)
|
|
||||||
except:
|
try:
|
||||||
ar = 'no self.addr!'
|
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):
|
def add_channel (self, map=None):
|
||||||
#self.log_info ('adding channel %s' % self)
|
#self.log_info ('adding channel %s' % self)
|
||||||
|
@ -299,6 +303,7 @@ class dispatcher:
|
||||||
|
|
||||||
def connect (self, address):
|
def connect (self, address):
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
|
# XXX why not use connect_ex?
|
||||||
try:
|
try:
|
||||||
self.socket.connect (address)
|
self.socket.connect (address)
|
||||||
except socket.error, why:
|
except socket.error, why:
|
||||||
|
|
Loading…
Reference in New Issue