New REPL: `python -q` outputs unnecessary blank space on empty terminal
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Bug report
Bug description:
If I start the new REPL on a clear terminal, I get an unnecessary blank space.
clear; python -q
Whereas this does not happen if I run the old ("basic") REPL:
clear; PYTHON_BASIC_REPL=1 python -q
Analysis
I've tracked this down to these 2 lines of code: https://github.com/python/cpython/blob/3.13/Lib/_pyrepl/unix_console.py#L241-L242
self.__move(0, len(self.screen) - 1)
self.__write("\n")
I don't totally understand this code, but it certainly smells like there's a bug here when dealing with an empty screen (for example, if len(self.screen) == 0, are we trying to move the cursor to index -1?)
I'm not sure what the fix is here, though. I don't really understand this code: why are we moving up to a line just to move the cursor down a line afterwards? why can't we jump straight to where we want to be? I tried digging through the git history for answers, but it looks like this incantation dates back all the way to this initial commit to pypi/pyrepl. I'm not sure how to dig any further back in time.
CPython versions tested on:
3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
I'm using Alacritty, in case that's relevant.
Linked PRs
- gh-131907
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’espace vide avec clear; python -q et comparez-le à PYTHON_BASIC_REPL=1 python -q. Lisez Lib/_pyrepl/unix_console.py autour des lignes 241-242, y compris les appels à __move et __write, et examinez la PR liée gh-131907. La tâche est terminée lorsque la nouvelle REPL n’émet plus l’espace vide inutile sur un terminal vide.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- cli
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100