prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.29k stars 715 forks source link

AttributeError: 'Stdout' object has no attribute 'isatty' in vt100.py #1234

Open Ed-SevenBit opened 4 years ago

Ed-SevenBit commented 4 years ago

Hit this error (trace below) running the Asynssh demo code from jonathanslenders. It was working so I don't know what happened.

Anyway, adding this to class Stdout in server.py seems to fix it, but I really don't know what I am doing. def isatty(s): return True

Perhaps someone who knows the code could take a look at it?

Traceback (most recent call last): File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/contrib/ssh/server.py", line 89, in _interact await self.interact(self) File "ethacli.py", line 65, in interact prompt_session = PromptSession() File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 466, in init self.app = self._create_application(editing_mode, erase_when_done) File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 717, in _create_application application: Application[_T] = Application( File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 310, in init self.renderer = Renderer( File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 362, in init if not output.responds_to_cpr: File "/mnt/pycode/ethametcli/venvcli/lib/python3.8/site-packages/prompt_toolkit/output/vt100.py", line 701, in responds_to_cpr return self.stdout.isatty() AttributeError: 'Stdout' object has no attribute 'isatty'

sthibaul commented 4 years ago

You'll probably want to rather return False