xml.dom.pulldom DOMEventStream drops SAX events produced by parser.close()
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
Issue
DOMEventStream.getEvent() silently drops SAX events that are produced when parser.close() is called at end-of-stream. When the stream is exhausted, getEvent() calls self.parser.close() and immediately returns None without checking whether close() generated new events. This causes END_ELEMENT and other trailing events to be lost when bufsize causes the final tag to be split across reads.
Reproducer
import io
from xml.dom.pulldom import parse
events = list(parse(io.BytesIO(b'<a></a>'), bufsize=2))
print([e for e, _ in events])
# ['START_DOCUMENT', 'START_ELEMENT'] — END_ELEMENT is missing
Iterating the DOMEventStream (via list()) internally calls getEvent(), which is where the bug lives.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145262
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da DOMEventStream.getEvent(), dove l’issue indica che parser.close() può produrre eventi che non vengono controllati. Esegui il reproducer BytesIO fornito con bufsize=2 e verifica che l’iterazione conservi l’evento END_ELEMENT finale; il PR collegato gh-145262 indica che il lavoro è già in corso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100