Issue #15179: Closed socket on connection failure. Thanks to Kazutaka Morita for the patch.
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 5af73e9..19a5f10 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -771,7 +771,11 @@
except socket.error:
self.socket.close()
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- self.socket.connect(address)
+ try:
+ self.socket.connect(address)
+ except socket.error:
+ self.socket.close()
+ raise
# curious: when talking to the unix-domain '/dev/log' socket, a
# zero-terminator seems to be required. this string is placed