`shlex.push_source()` fails to reset lexer state, causing new stream to be ignored if called after EOF
未關閉
還沒有人認領這個 Issue。
stdlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
Calling shlex.push_source() after the current input has reached EOF leaves the lexer in state == None, so the newly pushed source is never read. Subsequent get_token() calls immediately return EOF instead of consuming the new input.
from shlex import shlex
lexer = shlex('a')
print(lexer.get_token())
print(lexer.get_token()) # EOF -> state is None
lexer.push_source('b', None)
print(lexer.get_token()) # actural '' (EOF), expected: 'b'
a
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
gh-144560- gh-150172
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從入口點 shlex.shlex 開始,重現回報的序列:將初始輸入消耗到 EOF,呼叫 push_source('b', None),然後讀取下一個 token。完成的標誌是新推入的 source 被消耗,而不是回傳 EOF;為此序列新增或更新回歸測試涵蓋,並執行相關的 shlex 測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100