##// END OF EJS Templates
procutil: introduce pseudo file object that just raises EBADF...
Yuya Nishihara -
r46790:a1601ff3 default
parent child Browse files
Show More
@@ -50,6 +50,16 b' def isatty(fp):'
50 return False
50 return False
51
51
52
52
53 class BadFile(io.RawIOBase):
54 """Dummy file object to simulate closed stdio behavior"""
55
56 def readinto(self, b):
57 raise IOError(errno.EBADF, 'Bad file descriptor')
58
59 def write(self, b):
60 raise IOError(errno.EBADF, 'Bad file descriptor')
61
62
53 class LineBufferedWrapper(object):
63 class LineBufferedWrapper(object):
54 def __init__(self, orig):
64 def __init__(self, orig):
55 self.orig = orig
65 self.orig = orig
@@ -129,8 +139,7 b' if pycompat.ispy3:'
129 if sys.stdin:
139 if sys.stdin:
130 stdin = sys.stdin.buffer
140 stdin = sys.stdin.buffer
131 else:
141 else:
132 stdin = open(os.devnull, 'rb')
142 stdin = BadFile()
133 os.close(stdin.fileno())
134 stdout = _make_write_all(sys.stdout.buffer)
143 stdout = _make_write_all(sys.stdout.buffer)
135 stderr = _make_write_all(sys.stderr.buffer)
144 stderr = _make_write_all(sys.stderr.buffer)
136 if pycompat.iswindows:
145 if pycompat.iswindows:
General Comments 0
You need to be logged in to leave comments. Login now