From 5b0862e78ef05cdfe4015c0e81b6596943f102de Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Thu, 10 Apr 2025 10:30:09 -0400 Subject: [PATCH] PYTHON-5297 - AsyncMongoClient connection error causes UnboundLocalError (#2273) --- doc/changelog.rst | 7 ++++--- pymongo/pool_shared.py | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 3c307564b..e82804565 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,21 +1,22 @@ Changelog ========= + Changes in Version 4.12.1 (XXXX/XX/XX) -------------------------------------- Version 4.12.1 is a bug fix release. +- Fixed a bug that could raise ``UnboundLocalError`` when creating asynchronous connections over SSL. - Fixed a bug causing SRV hostname validation to fail when resolver and resolved hostnames are identical with three domain levels. Issues Resolved ............... -See the `PyMongo 4.12 release notes in JIRA`_ for the list of resolved issues +See the `PyMongo 4.12.1 release notes in JIRA`_ for the list of resolved issues in this release. -.. _PyMongo 4.12 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=41916 -.. _PYTHON-5288: https://jira.mongodb.org/browse/PYTHON-5288 +.. _PyMongo 4.12.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43094 Changes in Version 4.12.0 (2025/04/08) -------------------------------------- diff --git a/pymongo/pool_shared.py b/pymongo/pool_shared.py index a46a4d230..be7c416dc 100644 --- a/pymongo/pool_shared.py +++ b/pymongo/pool_shared.py @@ -346,12 +346,10 @@ async def _configured_protocol_interface( ssl=ssl_context, ) except _CertificateError: - transport.abort() # Raise _CertificateError directly like we do after match_hostname # below. raise except (OSError, SSLError) as exc: - transport.abort() # We raise AutoReconnect for transient and permanent SSL handshake # failures alike. Permanent handshake failures, like protocol # mismatch, will be turned into ServerSelectionTimeoutErrors later.