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

Function cleanup_traceback

Lib/idlelib/run.py:280–309  ·  view source on GitHub ↗

Remove excluded traces from beginning/end of tb; get cached lines

(tb, exclude)

Source from the content-addressed store, hash-verified

278 print_exc(typ, val, tb)
279
280def cleanup_traceback(tb, exclude):
281 "Remove excluded traces from beginning/end of tb; get cached lines"
282 orig_tb = tb[:]
283 while tb:
284 for rpcfile in exclude:
285 if tb[0][0].count(rpcfile):
286 break # found an exclude, break for: and delete tb[0]
287 else:
288 break # no excludes, have left RPC code, break while:
289 del tb[0]
290 while tb:
291 for rpcfile in exclude:
292 if tb[-1][0].count(rpcfile):
293 break
294 else:
295 break
296 del tb[-1]
297 if len(tb) == 0:
298 # exception was in IDLE internals, don't prune!
299 tb[:] = orig_tb[:]
300 print("** IDLE Internal Exception: ", file=sys.stderr)
301 rpchandler = rpc.objecttable['exec'].rpchandler
302 for i in range(len(tb)):
303 fn, ln, nm, line = tb[i]
304 if nm == '?':
305 nm = "-toplevel-"
306 if not line and fn.startswith("<pyshell#"):
307 line = rpchandler.remotecall('linecache', 'getline',
308 (fn, ln), {})
309 tb[i] = fn, ln, nm, line
310
311def flush_stdout():
312 """XXX How to do this now?"""

Callers 1

print_excFunction · 0.85

Calls 3

remotecallMethod · 0.80
countMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…