MCPcopy Index your code
hub / github.com/python/cpython / TruncatedStringIO

Class TruncatedStringIO

Tools/gdb/libpython.py:136–153  ·  view source on GitHub ↗

Similar to io.StringIO, but can truncate the output by raising a StringTruncated exception

Source from the content-addressed store, hash-verified

134 pass
135
136class TruncatedStringIO(object):
137 '''Similar to io.StringIO, but can truncate the output by raising a
138 StringTruncated exception'''
139 def __init__(self, maxlen=None):
140 self._val = ''
141 self.maxlen = maxlen
142
143 def write(self, data):
144 if self.maxlen:
145 if len(data) + len(self._val) > self.maxlen:
146 # Truncation:
147 self._val += data[0:self.maxlen - len(self._val)]
148 raise StringTruncated()
149
150 self._val += data
151
152 def getvalue(self):
153 return self._val
154
155
156def _PyStackRef_AsPyObjectBorrow(gdbval):

Callers 2

get_truncated_reprMethod · 0.85
get_truncated_reprMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…