Skip to content

fix(gateway; voice/reader): SyntaxWarning about return in a finally block - #3334

Merged
Lulalaby merged 4 commits into
masterfrom
fix/3332
Aug 7, 2026
Merged

fix(gateway; voice/reader): SyntaxWarning about return in a finally block#3334
Lulalaby merged 4 commits into
masterfrom
fix/3332

Conversation

@vmphase

@vmphase vmphase commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes #3332:
SyntaxWarning: 'return' in a 'finally' block (introduced in Python 3.14) in two places (ruff B012)

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • I have read the Contributing Guidelines.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

@vmphase
vmphase requested review from a team August 7, 2026 06:14
@vmphase
vmphase requested a review from Lulalaby August 7, 2026 06:14
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Aug 7, 2026
@pycord-app

pycord-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3334/head:pr-3334
git checkout pr-3334

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3334/head

Comment thread discord/gateway.py
Comment on lines +172 to +178
except BaseException:
_log.exception(
"An error occurred while stopping the gateway. Ignoring."
)
finally:
self.stop()
return
return

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For anyone interested why Exception was changed to BaseException: previously, a non-Exception failure from f.result() (e.g. SystemExit) wasn't caught here, so it fell into finally, where the return silently discarded it. Now it's explicitly caught and logged instead with same end result.

@Paillat-dev Paillat-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed from here:
IMG_20260807_104529.jpg

Lgtm please someone test but should be good it works in my brain

@vmphase

vmphase commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

Reviewed from here: IMG_20260807_104529.jpg

Lgtm please someone test but should be good it works in my brain

Wow. The most insane review place I've ever seen. Astonishing!

@Lulalaby
Lulalaby requested a review from JustaSqu1d August 7, 2026 08:49
@Paillat-dev
Paillat-dev enabled auto-merge (squash) August 7, 2026 09:33
@Lulalaby
Lulalaby disabled auto-merge August 7, 2026 15:30
@Lulalaby
Lulalaby merged commit c5e8f6d into master Aug 7, 2026
25 checks passed
@Lulalaby
Lulalaby deleted the fix/3332 branch August 7, 2026 15:30
@github-project-automation github-project-automation Bot moved this from Todo to Done in Pycord Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

return statements in finally blocks causing flaky SyntaxWarning

4 participants