diff -r a9d43e21f7d8 Lib/logging/handlers.py --- a/Lib/logging/handlers.py Sat May 19 08:12:00 2012 +0800 +++ b/Lib/logging/handlers.py Wed May 23 17:38:39 2012 +0400 @@ -605,14 +605,6 @@ SocketHandler.__init__(self, host, port) self.closeOnError = 0 - def makeSocket(self): - """ - The factory method of SocketHandler is here overridden to create - a UDP socket (SOCK_DGRAM). - """ - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return s - def send(self, s): """ Send a pickled string to a socket. @@ -621,9 +613,8 @@ when the network is busy - UDP does not guarantee delivery and can deliver packets out of sequence. """ - if self.sock is None: - self.createSocket() - self.sock.sendto(s, (self.host, self.port)) + sock = socket.create_connection((self.host, self.port), sockettype=socket.SOCK_DGRAM) + sock.send(s) class SysLogHandler(logging.Handler): """ diff -r a9d43e21f7d8 Lib/socket.py --- a/Lib/socket.py Sat May 19 08:12:00 2012 +0800 +++ b/Lib/socket.py Wed May 23 17:38:39 2012 +0400 @@ -127,7 +127,8 @@ Wait for an incoming connection. Return a new socket representing the connection, and the address of the client. - For IP sockets, the address info is a pair (hostaddr, port). + For IP sockets, the address info is a pair (hostaddr, port) for IPv4 + or (hostaddr, port, flowinfo, scopeid) for IPv6. """ fd, addr = self._accept() sock = socket(self.family, self.type, self.proto, fileno=fd) @@ -360,7 +361,7 @@ from gethostname() is returned. """ name = name.strip() - if not name or name == '0.0.0.0': + if not name or name == '0.0.0.0' or name == '::': name = gethostname() try: hostname, aliases, ipaddrs = gethostbyaddr(name) @@ -379,7 +380,8 @@ _GLOBAL_DEFAULT_TIMEOUT = object() def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, - source_address=None): + source_address=None, + sockettype=SOCK_STREAM): """Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, @@ -392,9 +394,9 @@ An host of '' or port 0 tells the OS to use the default. """ - host, port = address + host, port = address[:2] err = None - for res in getaddrinfo(host, port, 0, SOCK_STREAM): + for res in getaddrinfo(host, port, 0, sockettype): af, socktype, proto, canonname, sa = res sock = None try: