Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

wave.Wave_write.setparams() rejects valid PCM-to-IEEE-float parameter changes

オープン
#160,030 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

stdlib type-bug
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時間 30分
マージ済み PR(30日)
708

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。