Print checking swallows writes to explicit output streams

Aperta
#96 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@vinsymoyya ci sta già lavorando.

Dal 13/11/2026.

  • #97 di @vinsymoyya — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Start with the print interceptor that EvalExample.run_print_check() uses, and check how it handles the file keyword argument. Linked pull request #97 already targets this, so review its diff and discussion before writing anything. Done means the StringIO example from the issue passes, the stdout controls still pass, and the existing test suite stays green.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Reproduced on main at df945f7043cb8c456359b01700f3d664d30fbe44.

The print interceptor captures every call, including print(..., file=buffer). The destination never receives the text, so otherwise valid examples that use StringIO or another explicit text stream can fail their assertions.

from io import StringIO
buffer = StringIO()
print('hello', 'world', sep=':', end='!', file=buffer, flush=True)
assert buffer.getvalue() == 'hello:world!'

Run this through EvalExample.run_print_check(). The assertion fails because the buffer is empty.

Expected: checking/updating output preserves valid Python print semantics and produces compilable source.

Contract: https://docs.python.org/3/library/functions.html#print

The explicit-stream regression fails before the fix, while two stdout controls pass. All three pass afterward. The independently checked full local suite passes 84 tests with one expected failure and the known Windows object-address case deselected.

Relevant current and closed PR patches and issue discussions were checked; this does not duplicate the existing object-address, set-output, control-flow, metadata or indentation fixes.

Lingua principale
Python
Stelle
181
Fork
31
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pydantic/pytest-examples

Tutte le issue di pydantic/pytest-examples

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.