From 9c367210789fb7f389664658fe046d92f13c543c Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 19 Dec 2023 10:02:18 +0000 Subject: [PATCH 1/3] GH-113280: Fix ResourceWarning in ssl.SSLSocket connected detection --- Lib/ssl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/ssl.py b/Lib/ssl.py index d01484964b6895..a72c190425652f 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -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() @@ -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) From 3de7b3dd8adbb5f484fcad3f5083ec049f7aef5e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:05:51 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst diff --git a/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst b/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst new file mode 100644 index 00000000000000..694e2e0198e81e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst @@ -0,0 +1 @@ +Fix class:`ResourceWarning` in class:`ssl.SSLSocket` connected detection From a9b6d88f551ebab358025b4713afc754af0a9edc Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 19 Dec 2023 10:10:53 +0000 Subject: [PATCH 3/3] add missing colons to news --- .../next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst b/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst index 694e2e0198e81e..f4c9510031ed96 100644 --- a/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst +++ b/Misc/NEWS.d/next/Library/2023-12-19-10-05-45.gh-issue-113280.qIia3M.rst @@ -1 +1 @@ -Fix class:`ResourceWarning` in class:`ssl.SSLSocket` connected detection +Fix :class:`ResourceWarning` in :class:`ssl.SSLSocket` connected detection