File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1113,6 +1113,21 @@ def print_traceback(self):
1113
1113
lineno ,
1114
1114
self .co_name .proxyval (visited )))
1115
1115
1116
+ def get_truncated_repr (self , maxlen ):
1117
+ '''
1118
+ Get a repr-like string for the data, but truncate it at "maxlen" bytes
1119
+ (ending the object graph traversal as soon as you do)
1120
+ '''
1121
+ out = TruncatedStringIO (maxlen )
1122
+ try :
1123
+ self .write_repr (out , set ())
1124
+ except StringTruncated :
1125
+ # Truncation occurred:
1126
+ return out .getvalue () + '...(truncated)'
1127
+
1128
+ # No truncation occurred:
1129
+ return out .getvalue ()
1130
+
1116
1131
class PySetObjectPtr (PyObjectPtr ):
1117
1132
_typename = 'PySetObject'
1118
1133
@@ -1779,7 +1794,7 @@ def print_summary(self):
1779
1794
if self .is_evalframe ():
1780
1795
pyop = self .get_pyop ()
1781
1796
if pyop :
1782
- line = PyObjectPtr .get_truncated_repr (pyop , MAX_OUTPUT_LEN )
1797
+ line = pyop .get_truncated_repr (MAX_OUTPUT_LEN )
1783
1798
write_unicode (sys .stdout , '#%i %s\n ' % (self .get_index (), line ))
1784
1799
if not pyop .is_optimized_out ():
1785
1800
line = pyop .current_line ()
You can’t perform that action at this time.
0 commit comments