Print from background thread has broken line endings
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:
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
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 eseguendo lo script fornito in modalità interattiva su Linux con Python 3.13, quindi confronta il suo output con Python 3.12 e con la modalità non interattiva. Analizza la gestione del prompt interattivo e dell’output del thread in background; il lavoro è completato quando le righe del thread in background riportano il cursore all’inizio di ogni riga senza interrompere il prompt.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100