MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / cleanup_traceback

Function cleanup_traceback

tools/python-3.11.9-amd64/Lib/idlelib/run.py:272–301  ·  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

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

Callers 1

print_excFunction · 0.85

Calls 4

startswithMethod · 0.80
remotecallMethod · 0.80
printFunction · 0.50
countMethod · 0.45

Tested by

no test coverage detected