From 38a5ef521bbdbd808e7ab9c48ef10fcad2762efb 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) (cherry picked from commit 5b0862e78ef05cdfe4015c0e81b6596943f102de) --- doc/changelog.rst | 17 +++++++++++++++++ pymongo/pool_shared.py | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 077c85bb4b..e82804565f 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,6 +1,23 @@ 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.1 release notes in JIRA`_ for the list of resolved issues +in this release. + +.. _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 a46a4d2300..be7c416dc5 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.