`input` assumes the last character is a '\n' and always strips it
未關閉
還沒有人認領這個 Issue。
interpreter-core
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
When reading from the tty python's builtin input function assumes that the last character read is a newline and proceed to strip it out leading to missing input.
Current behaviour:
$ ./python -c 'print(repr(input()))'
abc'ab'
Expected behaviour:
$ ./python -c 'print(repr(input()))'
abc'abc'
CPython versions tested on:
3.14, 3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-149237
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
使用提供的 ./python -c 輸入命令重現問題,然後檢查 CPython 的 builtin input 實作以及相關的 PR gh-149237。當讀取的資料不以換行符號結尾時,tty 輸入不再遺失最後一個字元,且相關測試通過,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- cli, operating-systems
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100