Skip to content

Commit 30f7561

Browse files
authored
pyopenssl_context.py: Fix incorrect service_identity error names
When there is a mistake in the certificates configuration, PyMongo would give the following error: ``` pymongo.errors.ServerSelectionTimeoutError: module service_identity has no attribute SICertificateError, Timeout: 30s, Topology Description: <…> ``` Because the `except` block expected non-existing errors, the error gets transformed to "module … has no attribute …". The errors in the `service_identity` have never had the `SI` prefix: https://github.com/pyca/service-identity/blob/18.1.0/src/service_identity/exceptions.py It looks like the errors were imported with an alias before, but this aliasing was (only partially) removed when rewriting to lazy imports in this commit: 42a08c4#diff-b277a2f4cfbb5decab333d0b90a08a4ad64b91fb1691ed8412b15949d1aaceee The lazy imports were removed again in this commit, but the error remained: 49987e6#diff-b277a2f4cfbb5decab333d0b90a08a4ad64b91fb1691ed8412b15949d1aaceee Most likely, the `# type: ignore[misc]` comment can now also be removed.
1 parent 54846cd commit 30f7561

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pymongo/pyopenssl_context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ def wrap_socket(
420420
pyopenssl.verify_ip_address(ssl_conn, server_hostname)
421421
else:
422422
pyopenssl.verify_hostname(ssl_conn, server_hostname)
423-
except ( # type:ignore[misc]
424-
service_identity.SICertificateError,
425-
service_identity.SIVerificationError,
423+
except (
424+
service_identity.CertificateError,
425+
service_identity.VerificationError,
426426
) as exc:
427427
raise _CertificateError(str(exc)) from None
428428
return ssl_conn

0 commit comments

Comments
 (0)