PYTHON-5297 - AsyncMongoClient connection error causes UnboundLocalError (#2273)

This commit is contained in:
Noah Stapp 2025-04-10 10:30:09 -04:00 committed by GitHub
parent 86e221eb5c
commit 5b0862e78e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -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)
--------------------------------------

View File

@ -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.