Skip to content

Commit

Permalink
pythonGH-113280: Fix ResourceWarning in ssl.SSLSocket connected detec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
graingert committed Dec 19, 2023
1 parent d71fcde commit 9c36721
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
self.getpeername()
except OSError as e:
if e.errno != errno.ENOTCONN:
self.close()
raise
connected = False
blocking = self.getblocking()
Expand All @@ -1030,6 +1031,7 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
except OSError as e:
# EINVAL occurs for recv(1) on non-connected on unix sockets.
if e.errno not in (errno.ENOTCONN, errno.EINVAL):
self.close()
raise
notconn_pre_handshake_data = b''
self.setblocking(blocking)
Expand Down

0 comments on commit 9c36721

Please sign in to comment.