Skip to content

fix: remove return from finally block to resolve Python 3.14 SyntaxWarning#783

Merged
rithikanarayan merged 3 commits intomainfrom
rith/test
Apr 6, 2026
Merged

fix: remove return from finally block to resolve Python 3.14 SyntaxWarning#783
rithikanarayan merged 3 commits intomainfrom
rith/test

Conversation

@rithikanarayan
Copy link
Copy Markdown
Contributor

@rithikanarayan rithikanarayan commented Apr 6, 2026

What does this PR do?

This is a community PR #759

Removes return self.blocking_response from the finally block in _LambdaDecorator.call and defers it to after the try/except/finally block, eliminating the SyntaxWarning: 'return' in a 'finally' block emitted by Python 3.14 at cold start.

Motivation

Python 3.14 introduced a SyntaxWarning for return/break/continue inside finally blocks because a return in finally silently suppresses any exception actively propagating through the try/except. This warning was firing on every Lambda cold start and polluting CloudWatch logs for anyone running on the Python 3.14 runtime.

Fixes integration test snapshot changed introduced in #767.

Testing Guidelines

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@rithikanarayan rithikanarayan changed the title test fix: remove return from finally block to resolve Python 3.14 SyntaxWarning Apr 6, 2026
@rithikanarayan rithikanarayan marked this pull request as ready for review April 6, 2026 16:45
@rithikanarayan rithikanarayan requested review from a team as code owners April 6, 2026 16:45
Co-authored-by: Melissa Womack <melissa.j.womack@gmail.com>
@rithikanarayan rithikanarayan merged commit 8badbdb into main Apr 6, 2026
104 checks passed
@rithikanarayan rithikanarayan deleted the rith/test branch April 6, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants