]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-144975: Fix wave.Wave_write.setframerate() validation order (GH-144976)
authorMichiel W. Beijen <mb@x14.nl>
Tue, 17 Mar 2026 17:01:18 +0000 (18:01 +0100)
committerGitHub <noreply@github.com>
Tue, 17 Mar 2026 17:01:18 +0000 (18:01 +0100)
commitff287a72de43e7fc6517aba9049cb23470e000b2
tree61267581818a170a7dbe8091a29001bef9aab9b1
parentdc24b8a6d42231ebc821baeda662e1168b52aa26
gh-144975: Fix wave.Wave_write.setframerate() validation order (GH-144976)

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.
Lib/test/test_wave.py
Lib/wave.py
Misc/NEWS.d/next/Library/2026-02-18-21-45-00.gh-issue-144975.Ab3XyZ.rst [new file with mode: 0644]