MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / IOBuf

Class IOBuf

_pydevd_bundle/pydevd_io.py:115–144  ·  view source on GitHub ↗

This class works as a replacement for stdio and stderr. It is a buffer and when its contents are requested, it will erase what it has so far so that the next return will not return the same contents again.

Source from the content-addressed store, hash-verified

113
114
115class IOBuf:
116 """This class works as a replacement for stdio and stderr.
117 It is a buffer and when its contents are requested, it will erase what
118 it has so far so that the next return will not return the same contents again.
119 """
120
121 def __init__(self):
122 self.buflist = []
123 import os
124
125 self.encoding = os.environ.get("PYTHONIOENCODING", "utf-8")
126
127 def getvalue(self):
128 b = self.buflist
129 self.buflist = [] # clear it
130 return "".join(b) # bytes on py2, str on py3.
131
132 def write(self, s):
133 if isinstance(s, bytes):
134 s = s.decode(self.encoding, errors="replace")
135 self.buflist.append(s)
136
137 def isatty(self):
138 return False
139
140 def flush(self):
141 pass
142
143 def empty(self):
144 return len(self.buflist) == 0
145
146
147class _RedirectInfo(object):

Callers 2

pushMethod · 0.90
start_redirectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected