Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc816865

Browse files
add more methods to fake stdin/err/out
1 parentd796bca commitc816865

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎bpython/curtsiesfrontend/coderunner.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def __init__(self, coderunner, please):
115115
defwrite(self,*args,**kwargs):
116116
self.please(*args,**kwargs)
117117
returnself.coderunner.refresh_and_get_value()
118+
defwritelines(self,l):
119+
forsinl:
120+
self.write(s)
121+
defflush(self):
122+
pass
123+
defisatty(self):
124+
returnTrue
118125

119126
deftest_simple():
120127
orig_stdout=sys.stdout

‎bpython/curtsiesfrontend/repl.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importgreenlet
88
importsubprocess
99
importtempfile
10+
importerrno
1011

1112
frombpython.autocompleteimportAutocomplete,SIMPLE
1213
frombpython.replimportReplasBpythonRepl
@@ -90,6 +91,26 @@ def readline(self):
9091
self.readline_results.append(value)
9192
returnvalue
9293

94+
defreadlines(self,size=-1):
95+
returnlist(iter(self.readline,''))
96+
97+
def__iter__(self):
98+
returniter(self.readlines())
99+
100+
defisatty(self):
101+
returnTrue
102+
103+
defflush(self):
104+
"""Flush the internal buffer. This is a no-op. Flushing stdin
105+
doesn't make any sense anyway."""
106+
107+
defwrite(self,value):
108+
# XXX IPython expects sys.stdin.write to exist, there will no doubt be
109+
# others, so here's a hack to keep them happy
110+
raiseIOError(errno.EBADF,"sys.stdin is read-only")
111+
112+
#TODO write a read() method
113+
93114
classReevaluateFakeStdin(object):
94115
def__init__(self,fakestdin,repl):
95116
self.fakestdin=fakestdin

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp