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 97b76b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ def __init__(self, *args, **kwargs):
@classmethod
def _create(cls, incoming, outgoing, server_side=False,
server_hostname=None, session=None, context=None):
import traceback
traceback.print_stack()
self = cls.__new__(cls)
sslobj = context._wrap_bio(
incoming, outgoing, server_side=server_side,
Expand Down Expand Up @@ -1017,6 +1019,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 +1033,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 97b76b3

Please sign in to comment.