-
Notifications
You must be signed in to change notification settings - Fork 255
Eliminate usage of 'return' in 'finally' blocks #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change helps make the code compatible with Python 3.14, where 'return' in finally blocks is no longer allowed.
There was a problem hiding this 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 refactors code to eliminate the use of return statements within finally blocks to ensure compatibility with Python 3.14, where this pattern will no longer be allowed. The changes affect exception handling and control flow in two critical modules.
Key changes:
- Removed
finallyblock withreturnstatement inbilliard/pool.py:_ack()method and moved the conditional return logic outside the try-except block - Refactored
billiard/connection.py:_recv_bytes()to use deferred return/raise pattern instead of returning fromfinallyblock
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| billiard/pool.py | Simplified exception handling in _ack() by removing the finally block and moving the acknowledgment send logic after the try-except block |
| billiard/connection.py | Refactored Windows pipe connection's _recv_bytes() to store result and exception state variables, enabling return/raise after finally block completes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
@auvipy Hi 👋🏻 Yes, my own analysis was that by catching So these changes LGTM 👍🏼 |
Nusnus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change helps make the code compatible with Python 3.14, where 'return' in finally blocks is no longer allowed.