diff --git a/pymongo/asynchronous/srv_resolver.py b/pymongo/asynchronous/srv_resolver.py index 9d1b8fe141..8d0d40c276 100644 --- a/pymongo/asynchronous/srv_resolver.py +++ b/pymongo/asynchronous/srv_resolver.py @@ -107,7 +107,7 @@ async def get_options(self) -> Optional[str]: # No TXT records return None except Exception as exc: - raise ConfigurationError(str(exc)) from None + raise ConfigurationError(str(exc)) from exc if len(results) > 1: raise ConfigurationError("Only one TXT record is supported") return (b"&".join([b"".join(res.strings) for res in results])).decode("utf-8") # type: ignore[attr-defined] @@ -122,7 +122,7 @@ async def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer: # Raise the original error. raise # Else, raise all errors as ConfigurationError. - raise ConfigurationError(str(exc)) from None + raise ConfigurationError(str(exc)) from exc return results async def _get_srv_response_and_hosts( @@ -145,8 +145,8 @@ async def _get_srv_response_and_hosts( ) try: nlist = srv_host.split(".")[1:][-self.__slen :] - except Exception: - raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None + except Exception as exc: + raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc if self.__plist != nlist: raise ConfigurationError(f"Invalid SRV host: {node[0]}") if self.__srv_max_hosts: diff --git a/pymongo/synchronous/srv_resolver.py b/pymongo/synchronous/srv_resolver.py index 0817c6dcd7..f6e99a3ea8 100644 --- a/pymongo/synchronous/srv_resolver.py +++ b/pymongo/synchronous/srv_resolver.py @@ -107,7 +107,7 @@ def get_options(self) -> Optional[str]: # No TXT records return None except Exception as exc: - raise ConfigurationError(str(exc)) from None + raise ConfigurationError(str(exc)) from exc if len(results) > 1: raise ConfigurationError("Only one TXT record is supported") return (b"&".join([b"".join(res.strings) for res in results])).decode("utf-8") # type: ignore[attr-defined] @@ -122,7 +122,7 @@ def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer: # Raise the original error. raise # Else, raise all errors as ConfigurationError. - raise ConfigurationError(str(exc)) from None + raise ConfigurationError(str(exc)) from exc return results def _get_srv_response_and_hosts( @@ -145,8 +145,8 @@ def _get_srv_response_and_hosts( ) try: nlist = srv_host.split(".")[1:][-self.__slen :] - except Exception: - raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None + except Exception as exc: + raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc if self.__plist != nlist: raise ConfigurationError(f"Invalid SRV host: {node[0]}") if self.__srv_max_hosts: diff --git a/test/lambda/build_internal.sh b/test/lambda/build_internal.sh index fec488d32c..84423db4d1 100755 --- a/test/lambda/build_internal.sh +++ b/test/lambda/build_internal.sh @@ -1,5 +1,5 @@ #!/bin/bash -ex cd /src -PYTHON=/opt/python/cp39-cp39/bin/python +PYTHON=/opt/python/cp310-cp310/bin/python $PYTHON -m pip install -v -e . diff --git a/test/lambda/template.yaml b/test/lambda/template.yaml index 651ac4a8f8..11052f88dd 100644 --- a/test/lambda/template.yaml +++ b/test/lambda/template.yaml @@ -23,7 +23,7 @@ Resources: Variables: MONGODB_URI: !Ref MongoDbUri Handler: app.lambda_handler - Runtime: python3.9 + Runtime: python3.10 Architectures: - x86_64 Events: