xml.dom.pulldom DOMEventStream drops SAX events produced by parser.close()
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 DOMEventStream.getEvent() 開始,issue 指出 parser.close() 可能會產生未經檢查的事件。使用 bufsize=2 執行提供的 BytesIO reproducer,並驗證疊代會保留結尾的 END_ELEMENT 事件;連結的 PR gh-145262 表示相關工作已經在進行中。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100