wave.Wave_write.setparams() rejects valid PCM-to-IEEE-float parameter changes
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Python
- Estrelas
- 77.7k
- Forks
- 38.3k
- Merge médio
- 13h 43min
- PRs com merge (30d)
- 704
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/cpython
-
topic-socket type-bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python/cpython#160561 · 7 comentários ·
Mantenedores costumam responder em até 1 dia
-
tests topic-profiling type-bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python/cpython#160334 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
`iso2022_jp_3` encodes U+9B1D but decodes the result as U+9B1CTalvez já em andamento @kinqsradio assumiu há 1 dia. Abertaextension-modules type-bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia
-
Remove unused FVS_* macrosAbertainterpreter-core type-feature
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
python/cpython#160109 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
extension-modules type-bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python/cpython#160001 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de python/cpython
Issues semelhantes
-
bug P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Toloka/tolokaforge#1947 ·
Mantenedores costumam responder em até 1 dia
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpointsTalvez já em andamento @balajiaru assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
pydot/pydot#601 · 4 comentários ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
letsencrypt/cp-cps#361 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100