wave.Wave_write.setparams() rejects valid PCM-to-IEEE-float parameter changes
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
The issue identifies Lib/wave.py, specifically Wave_write.setparams(), setformat(), and setsampwidth(). Read those methods and the tests for IEEE float support, then reproduce the PCM-to-float reconfiguration case from the report. Done means valid 4-byte and 8-byte float parameters can be set before any frames are written, including after PCM widths of 1, 2, or 3 bytes.
由索引模型根據 Issue 內容生成。
描述
Bug report
Bug description
wave.Wave_write.setparams() rejects valid IEEE-float parameters when the writer was previously configured with a PCM sample width of 1, 2, or 3 bytes, even though no audio frames have been written.
The same parameters succeed on a fresh writer.
Reproducer
import io
import wave
float_params = (
1, 4, 8000, 0, "NONE", "not compressed",
wave.WAVE_FORMAT_IEEE_FLOAT,
)
with wave.open(io.BytesIO(), "wb") as writer:
writer.setparams(float_params)
print("Fresh writer: OK")
with wave.open(io.BytesIO(), "wb") as writer:
writer.setparams((1, 2, 8000, 0, "NONE", "not compressed"))
writer.setparams(float_params)
print("Reconfigured writer: OK")
Actual behavior
The fresh-writer configuration succeeds. Reconfiguring the PCM writer raises:
wave.Error: unsupported sample width for IEEE float format
Expected behavior
Both configurations should succeed. The new sample width is 4 bytes, which is supported for IEEE float, and no frames have been written.
Implementation details
Wave_write.setparams() calls setformat(format) before
setsampwidth(sampwidth).
However, setformat() validates the existing self._sampwidth against the
new format. This rejects the previous 2-byte PCM width before the valid
new 4-byte width can be installed.
The same failure occurs when switching from PCM widths of 1, 2, or 3 bytes
to either 4-byte or 8-byte IEEE float. Switching from 4-byte PCM succeeds.
Related: #60729 added IEEE-float support.
CPython versions tested on
Python 3.16.0a1+dev, debug build based on commit 8b7d6c53eee.
Also reproduced using Lib/wave.py from upstream commit
f5bd07700ecd0f02cc424666b871f51de03b9232, executed under Python 3.14.8.
This additional check was not a full build of that upstream commit.
Operating systems tested on
macOS
Output from running python -VV
Python 3.16.0a1+dev (heads/gh-159868-userstring-affixes-dirty:8b7d6c53eee, Oct 20 2026, 15:46:41) [Clang 21.0.0 (clang-2100.3.34.2)]
CPython versions tested on:
3.16
Operating systems tested on:
macOS
Linked PRs
- gh-160031
- 主要語言
- Python
- 星號
- 77.7k
- 分支
- 38.3k
- 平均合併
- 13 小時 43 分鐘
- 30 天內合併 PR
- 704
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
topic-socket type-bug
難度 2/5 1-3 小時 新手友好度 72/100
python/cpython#160561 · 7 則留言 ·
維護者通常 1 天內回覆
-
tests topic-profiling type-bug
難度 2/5 1-3 小時 新手友好度 78/100
python/cpython#160334 · 1 則留言 ·
維護者通常 1 天內回覆
-
`iso2022_jp_3` encodes U+9B1D but decodes the result as U+9B1C可能已有人在做 @kinqsradio 於 1 天前認領。 未關閉extension-modules type-bug
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
interpreter-core type-feature
難度 1/5 1 小時以內 新手友好度 78/100
python/cpython#160109 · 1 則留言 ·
維護者通常 1 天內回覆
-
extension-modules type-bug
難度 2/5 1-3 小時 新手友好度 72/100
python/cpython#160001 · 3 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
bug P1
難度 2/5 1-3 小時 新手友好度 76/100
Toloka/tolokaforge#1947 ·
維護者通常 1 天內回覆
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpoints可能已有人在做 @balajiaru 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
letsencrypt/cp-cps#361 ·
-
難度 2/5 1-3 小時 新手友好度 65/100