Skip to content

Commit 328fd7b

Browse files
committed
add a hack to add a write() method to our fake stdin object to keep e.g. IPython happy
1 parent 5e24f65 commit 328fd7b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bpython/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import termios
3939
import fcntl
4040
import unicodedata
41+
import errno
42+
4143
from itertools import takewhile
4244
from locale import LC_ALL, getpreferredencoding, setlocale
4345
from optparse import OptionParser
@@ -103,6 +105,11 @@ def __init__(self, interface):
103105
def __iter__(self):
104106
return iter(self.readlines())
105107

108+
def write(self, value):
109+
# XXX IPython expects sys.stdin.write to exist, there will no doubt be
110+
# others, so here's a hack to keep them happy
111+
raise IOError(errno.EBADF, "sys.stdin is read-only")
112+
106113
def isatty(self):
107114
return True
108115

0 commit comments

Comments
 (0)