Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions 27 Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,14 +760,29 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
self.unixsocket = 1
self._connect_unixsocket(address)
else:
self.unixsocket = 0
self.unixsocket = False
if socktype is None:
socktype = socket.SOCK_DGRAM
self.socket = socket.socket(socket.AF_INET, socktype)
if socktype == socket.SOCK_STREAM:
self.socket.connect(address)
host, port = address
ress = socket.getaddrinfo(host, port, 0, socktype)
if not ress:
raise socket.error("getaddrinfo returns an empty list")
for res in ress:
af, socktype, proto, _, sa = res
err = sock = None
try:
sock = socket.socket(af, socktype, proto)
if socktype == socket.SOCK_STREAM:
sock.connect(sa)
break
except socket.error as exc:
err = exc
if sock is not None:
sock.close()
if err is not None:
raise err
self.socket = sock
self.socktype = socktype
self.formatter = None

def _connect_unixsocket(self, address):
use_socktype = self.socktype
Expand Down Expand Up @@ -812,7 +827,7 @@ def encodePriority(self, facility, priority):
priority = self.priority_names[priority]
return (facility << 3) | priority

def close (self):
def close(self):
"""
Closes the socket.
"""
Expand Down
3 changes: 3 additions & 0 deletions 3 Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Extension Modules
Library
-------

- bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
handle IPv6 addresses.

- bpo-29960: Preserve generator state when _random.Random.setstate()
raises an exception. Patch by Bryan Olson.

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.