MCPcopy Create free account
hub / github.com/ipython/ipython / _fixed_getinnerframes

Function _fixed_getinnerframes

IPython/core/ultratb.py:347–374  ·  view source on GitHub ↗
(etb, context=1, tb_offset=0)

Source from the content-addressed store, hash-verified

345
346@with_patch_inspect
347def _fixed_getinnerframes(etb, context=1, tb_offset=0):
348 LNUM_POS, LINES_POS, INDEX_POS = 2, 4, 5
349
350 records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
351 # If the error is at the console, don't build any context, since it would
352 # otherwise produce 5 blank lines printed out (there is no file at the
353 # console)
354 rec_check = records[tb_offset:]
355 try:
356 rname = rec_check[0][1]
357 if rname == '<ipython console>' or rname.endswith('<string>'):
358 return rec_check
359 except IndexError:
360 pass
361
362 aux = traceback.extract_tb(etb)
363 assert len(records) == len(aux)
364 for i, (file, lnum, _, _) in enumerate(aux):
365 maybeStart = lnum - 1 - context // 2
366 start = max(maybeStart, 0)
367 end = start + context
368 lines = linecache.getlines(file)[start:end]
369 buf = list(records[i])
370 buf[LNUM_POS] = lnum
371 buf[INDEX_POS] = lnum - 1 - start
372 buf[LINES_POS] = lines
373 records[i] = tuple(buf)
374 return records[tb_offset:]
375
376# Helper function -- largely belongs to VerboseTB, but we need the same
377# functionality to produce a pseudo verbose TB for SyntaxErrors, so that they

Callers 1

get_recordsMethod · 0.85

Calls 1

Tested by

no test coverage detected