Skip to content

gh-144975: Fix wave.Wave_write.setframerate() validation order#144976

Merged
encukou merged 3 commits intopython:mainfrom
mbeijen:wave-setframerate
Mar 17, 2026
Merged

gh-144975: Fix wave.Wave_write.setframerate() validation order#144976
encukou merged 3 commits intopython:mainfrom
mbeijen:wave-setframerate

Conversation

@mbeijen
Copy link
Contributor

@mbeijen mbeijen commented Feb 18, 2026

Validate the frame rate after rounding to an integer, not before. This prevents values like 0.5 from passing validation (0.5 > 0) but then rounding to 0, which would cause a confusing delayed error "sampling rate not specified" when writing frames.

With this fix, setframerate(0.5) immediately raises "bad frame rate", providing clear feedback at the point of the error.

See #144975

Validate the frame rate after rounding to an integer, not before.
This prevents values like 0.5 from passing validation (0.5 > 0)
but then rounding to 0, which would cause a confusing delayed error
"sampling rate not specified" when writing frames.

With this fix, setframerate(0.5) immediately raises "bad frame rate",
providing clear feedback at the point of the error.
Copy link
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

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

Thank you!

I pushed a commit directly: We have a little helper to "parametrize" tests, so that the first failure doesn't mask the rest.

Do the tests look good to you?

@mbeijen
Copy link
Contributor Author

mbeijen commented Mar 17, 2026

Thank you!

I pushed a commit directly: We have a little helper to "parametrize" tests, so that the first failure doesn't mask the rest.

Do the tests look good to you?

Elegant, thanks!!!

@encukou encukou merged commit ff287a7 into python:main Mar 17, 2026
51 checks passed
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.

2 participants