-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Labels
agent-pythoncommunityIssues opened by the communityIssues opened by the communitytriageIssues awaiting triageIssues awaiting triage
Description
Description
When running with Python 3.14, elastic-apm emits multiple SyntaxError messages about return statements inside finally blocks:
File "/usr/local/lib/python3.14/site-packages/elasticapm/contrib/django/middleware/__init__.py", line 114
return response
^^^^^^^^^^^^^^^
SyntaxError: 'return' in a 'finally' block
Why This Matters
Using return inside a finally block is problematic because:
- It silently swallows any exceptions that were raised in the try block
- It masks the original exception, making debugging difficult
- Python 3.14 now explicitly warns about this pattern
Affected Files
elasticapm/contrib/django/middleware/__init__.py (line 114 and 129)
Proposed Fix
Refactor the code to move the return statements outside of the finally blocks while preserving the intended behavior.
Environment
- Python version: 3.14
- eslastic-apm version: latest (main branch)
Metadata
Metadata
Assignees
Labels
agent-pythoncommunityIssues opened by the communityIssues opened by the communitytriageIssues awaiting triageIssues awaiting triage