Print from background thread has broken line endings
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
I noticed that in python 3.13 (in linux), messages that were previously logged nicely to the console are now behaving as if the lines end like a windows line feed character without carriage return -- the cursor moves down a row, but not back to the beginning of the line. The example I chose below looks tame, but it makes most real logging output very difficult to read.
This only seems to happen for lines printed from background threads:
import threading, time
def msg():
print('this is line 1')
print('this is line 2')
time.sleep(0.1) # first few lines work as expected, but after a brief time, the problem begins
print('this is line 3')
print('this is line 4')
thread = threading.Thread(target=msg)
thread.start()
Running this code in python 3.13.1, interactive mode looks like:
$ python -i print_test.py
this is line 1
this is line 2
>>> this is line 3
this is line 4
>>>
Non-interactive looks fine:
$ python print_test.py
this is line 1
this is line 2
this is line 3
this is line 4
And interactive in 3.12.8 looks fine:
$ python -i print_test.py
this is line 1
this is line 2
>>> this is line 3
this is line 4
CPython versions tested on:
3.13
Operating systems tested on:
Linux
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在 Linux 上使用 Python 3.13 以交互模式运行提供的脚本,然后将其输出与 Python 3.12 和非交互模式下的输出进行比较。调查交互式提示符和后台线程输出的处理方式;完成标准是后台线程的行将光标返回到每行开头,同时不干扰提示符。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100