Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ targets:
- python3.6
- python3.7
- python3.8
- python3.9
license: MIT
changelog: CHANGELOG.md
changelogPolicy: simple
18 changes: 14 additions & 4 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,33 @@ def get_lambda_bootstrap():
# Python 3.7: If the bootstrap module is *already imported*, it is the
# one we actually want to use (no idea what's in __main__)
#
# On Python 3.8 bootstrap is also importable, but will be the same file
# Python 3.8: bootstrap is also importable, but will be the same file
# as __main__ imported under a different name:
#
# sys.modules['__main__'].__file__ == sys.modules['bootstrap'].__file__
# sys.modules['__main__'] is not sys.modules['bootstrap']
#
# Python 3.9: bootstrap is in __main__.awslambdaricmain
#
# On container builds using the `aws-lambda-python-runtime-interface-client`
# (awslamdaric) module, bootstrap is located in sys.modules['__main__'].bootstrap
#
# Such a setup would then make all monkeypatches useless.
if "bootstrap" in sys.modules:
return sys.modules["bootstrap"]
elif "__main__" in sys.modules:
if hasattr(sys.modules["__main__"], "bootstrap"):
module = sys.modules["__main__"]
# python3.9 runtime
if hasattr(module, "awslambdaricmain") and hasattr(
Comment thread
tomscytale marked this conversation as resolved.
module.awslambdaricmain, "bootstrap" # type: ignore
):
return module.awslambdaricmain.bootstrap # type: ignore
elif hasattr(module, "bootstrap"):
# awslambdaric python module in container builds
return sys.modules["__main__"].bootstrap # type: ignore
return sys.modules["__main__"]
return module.bootstrap # type: ignore

# python3.8 runtime
return module
else:
return None

Expand Down
4 changes: 3 additions & 1 deletion tests/integrations/aws_lambda/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def lambda_client():
return get_boto_client()


@pytest.fixture(params=["python3.6", "python3.7", "python3.8", "python2.7"])
@pytest.fixture(
params=["python3.6", "python3.7", "python3.8", "python3.9", "python2.7"]
)
def lambda_runtime(request):
return request.param

Expand Down