Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#160,030 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
python
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
Python
Étoiles
77.7k
Forks
38.3k
Merge moyen
13 h 43 min
PR mergées (30 j)
704

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python/cpython

Toutes les issues de python/cpython

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.