Skip to content

FIX: Remove return in finally that swallows exceptions (#417)#526

Merged
bewithgaurav merged 2 commits into
devfrom
bewithgaurav/fix-return-in-finally-417
May 22, 2026
Merged

FIX: Remove return in finally that swallows exceptions (#417)#526
bewithgaurav merged 2 commits into
devfrom
bewithgaurav/fix-return-in-finally-417

Conversation

@bewithgaurav
Copy link
Copy Markdown
Collaborator

Issue: #417

Simplify _check_jsonfield_supported_sqlite() to return directly from try/except instead of using a variable with return in finally.

The finally-return pattern silently swallows all exceptions including KeyboardInterrupt and other BaseException subclasses.

Test-only change, no production code affected.

Simplify _check_jsonfield_supported_sqlite() to return directly
from try/except instead of using a variable with return in finally.
The finally-return pattern silently swallows all exceptions including
KeyboardInterrupt and other BaseExceptions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 21, 2026 18:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a test helper in testapp to avoid the Python anti-pattern of returning from a finally block, which would otherwise swallow in-flight exceptions (including BaseException subclasses like KeyboardInterrupt). This aligns the test suite with correct exception propagation behavior while keeping the helper’s intent (detecting SQLite JSON function support) unchanged.

Changes:

  • Refactored _check_jsonfield_supported_sqlite() to return True/False directly from the try / except blocks.
  • Removed the finally: return ... pattern that suppressed unexpected exceptions during the support check.

Comment thread testapp/tests/test_jsonfield.py
@bewithgaurav bewithgaurav merged commit 574f470 into dev May 22, 2026
65 checks passed
This was referenced May 22, 2026
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