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.11k stars 717 forks source link

OSError: [Errno 9] Bad file descriptor #1121

Open yathindran opened 4 years ago

yathindran commented 4 years ago

https://github.com/prompt-toolkit/python-prompt-toolkit/blob/dcc7adf0d5bcd0fd9db32ade713caaa56edbf757/prompt_toolkit/input/vt100.py#L262

This happens when you are triggering a python file inside of xcode. Does not happen on terminal.

line 55, in main in_str = prompt(str) File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1361, in prompt return session.prompt( File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt return self.app.run(set_exception_handler=set_exception_handler) File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run return loop.run_until_complete( File "/usr/local/Cellar/python@3.8/3.8.2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async return await _run_async2() File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2 result = await _run_async() File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 682, in _run_async with self.input.raw_mode(): File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/input/vt100.py", line 262, in __enter__ os.write(self.fileno, b"\x1b[?1l") OSError: [Errno 9] Bad file descriptor

jonathanslenders commented 4 years ago

Does xcode allocate a real pseudo terminal? Can you run for instance Vim and Emacs in there?

geekscrapy commented 4 years ago

Hi, I just tried importing it into the visidata project to try and improve the prompt that is in there already but got the same error. I know it was a long shot but I thought I'd try! I'm pretty sure visidata is built purely on curses with no additional libs, which in a way makes it a little hard to dev for if you need higher abstractions! So, given this, is there a way to pass the current screen object to prompt_toolkit for it to use? Long shot but I thought I'd ask! TIA!