prompt-toolkit / prompt-toolkit/python-prompt-toolkit
patch_stdout corrupts terminal output if lots of output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Run this example program on OSX 10.13.5 terminal & a bunch of garbage escaped escape codes are printed to the screen.
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
from prompt_toolkit.patch_stdout import patch_stdout
from prompt_toolkit.shortcuts import CompleteStyle
from prompt_toolkit.shortcuts.prompt import prompt
from threading import Thread
from prompt_toolkit.output.vt100 import Vt100_Output
import time
def spam_print():
while True:
print("This is spam")
Thread(target=spam_print, daemon=True).start()
while True:
with patch_stdout():
prompt("> ", rprompt="test", complete_style=CompleteStyle.MULTI_COLUMN,
completer=WordCompleter(list(chr(c) * 20 for c in range(ord("a"), ord("z")))))
Example corruption pasted below. Sometimes the terminal will even output the bell sound which to me indicates this corruption also sometimes manifests as the escape codes being written raw to the terminal. I have been unable to track down where/how the escape codes/buffer corruption is coming in (looks fine AFAICT within the patch proxy).
This is spam
This is spam
This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
^[[57;1R^[[51;9R^[[51;17R^[[51;26R^[[51;35R^[[51;44R^[[51;53R^[[51;62R^[[51;71R^[[51;80R^[[51;89R^[[51;98R^[[51;107R^[[51;117R^[[51;127R^[[51;137R^[[51;147R^[[51;157R^[[51;167R^[[51;177R^[[51;187R^[[51;197R^This is spam
This is spam
This is spam
This is spam
This is spam
This is spam
This is spam
This is spam
This is spam
This is spam
^[[51;3R^[[51;9R^[[51;17RThis is spam
This is spam
This is spam
This is spam
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python reproducer on the stated macOS terminal, then inspect prompt_toolkit.patch_stdout and the imported Vt100_Output path while observing output under heavy concurrent printing. Compare the patch proxy output with the terminal output. Done means repeated spam no longer produces raw escape sequences or bell sounds during prompt().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100