problems about sys.stdin.read() in ipython console

243 views
Skip to first unread message

YuFei Duan

unread,
Dec 11, 2021, 4:29:25 PM12/11/21
to spyder
Problem Description

These days I am trying to write a remote shell with python. I used winpwn module, which based on threading and standard io. Now I want to improve these things and found a quesion:

sys.stdin.read() is unavaliable in IPython Console.

this problem might relate to another quesion:

Unsupported operation sys.stdout.fileno() in IPython Console

because of these questions, I cannot use standard io by os.read or os.write in IPython Console, which is meaningful to my continued work

Now I am using Spyder 5.1.5 | Python 3.9.7 64-bit | Qt 5.9.7 | PyQt5 5.9.2 | Windows 10 | IPython 7.29.0

I tried the same operations above in pycharm's IPython Console (7.29.0), and it all work in pycharm.

What steps reproduce the problem?
  1. import sys and input "sys.stdin.read()"
  2. input "sys.stdout.fileno()"
What is the expected output? What do you see instead?
  1. it should be like input function but I got flash and no input.
  2. it should return an integer about file descriptor (1 if stdout) according to pycharm but I got Exception.
Paste Traceback/Error Below (if applicable)
import sys 
sys.stdin.read() 
Out[2]: ''

In [3]: sys.stdout.fileno() 
Traceback (most recent call last): File "C:\Users\10310\AppData\Local\Temp/ipykernel_24744/2810973561.py", line 1, in <module> sys.stdout.fileno() 
 File "C:\Users\10310\anaconda3\lib\site-packages\ipykernel\iostream.py", line 308, in fileno 
raise io.UnsupportedOperation("fileno") 
UnsupportedOperation: fileno
Versions
  • Spyder version: 5.1.5
  • Python version: 3.9.7
  • Qt version: 5.9.7
  • PyQt version: 5.9.2
  • Operating System name/version: Windows 10
Reply all
Reply to author
Forward
0 new messages