Skip to content

Commit a7a645f

Browse files
authored
PYTHON-5555 Fix AWS Lambda build (mongodb#2540)
1 parent 5787acc commit a7a645f

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pymongo/asynchronous/srv_resolver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def get_options(self) -> Optional[str]:
107107
# No TXT records
108108
return None
109109
except Exception as exc:
110-
raise ConfigurationError(str(exc)) from None
110+
raise ConfigurationError(str(exc)) from exc
111111
if len(results) > 1:
112112
raise ConfigurationError("Only one TXT record is supported")
113113
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:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
raise ConfigurationError(str(exc)) from None
125+
raise ConfigurationError(str(exc)) from exc
126126
return results
127127

128128
async def _get_srv_response_and_hosts(
@@ -145,8 +145,8 @@ async def _get_srv_response_and_hosts(
145145
)
146146
try:
147147
nlist = srv_host.split(".")[1:][-self.__slen :]
148-
except Exception:
149-
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None
148+
except Exception as exc:
149+
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc
150150
if self.__plist != nlist:
151151
raise ConfigurationError(f"Invalid SRV host: {node[0]}")
152152
if self.__srv_max_hosts:

pymongo/synchronous/srv_resolver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_options(self) -> Optional[str]:
107107
# No TXT records
108108
return None
109109
except Exception as exc:
110-
raise ConfigurationError(str(exc)) from None
110+
raise ConfigurationError(str(exc)) from exc
111111
if len(results) > 1:
112112
raise ConfigurationError("Only one TXT record is supported")
113113
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:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
raise ConfigurationError(str(exc)) from None
125+
raise ConfigurationError(str(exc)) from exc
126126
return results
127127

128128
def _get_srv_response_and_hosts(
@@ -145,8 +145,8 @@ def _get_srv_response_and_hosts(
145145
)
146146
try:
147147
nlist = srv_host.split(".")[1:][-self.__slen :]
148-
except Exception:
149-
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from None
148+
except Exception as exc:
149+
raise ConfigurationError(f"Invalid SRV host: {node[0]}") from exc
150150
if self.__plist != nlist:
151151
raise ConfigurationError(f"Invalid SRV host: {node[0]}")
152152
if self.__srv_max_hosts:

test/lambda/build_internal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash -ex
22

33
cd /src
4-
PYTHON=/opt/python/cp39-cp39/bin/python
4+
PYTHON=/opt/python/cp310-cp310/bin/python
55
$PYTHON -m pip install -v -e .

test/lambda/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Resources:
2323
Variables:
2424
MONGODB_URI: !Ref MongoDbUri
2525
Handler: app.lambda_handler
26-
Runtime: python3.9
26+
Runtime: python3.10
2727
Architectures:
2828
- x86_64
2929
Events:

0 commit comments

Comments
 (0)