MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_code_position

Function _get_code_position

Lib/inspect.py:1561–1566  ·  view source on GitHub ↗
(code, instruction_index)

Source from the content-addressed store, hash-verified

1559 return _get_code_position(code, instruction_index)
1560
1561def _get_code_position(code, instruction_index):
1562 if instruction_index < 0:
1563 return (None, None, None, None)
1564 positions_gen = code.co_positions()
1565 # The nth entry in code.co_positions() corresponds to instruction (2*n)th since Python 3.10+
1566 return next(itertools.islice(positions_gen, instruction_index // 2, None))
1567
1568def getframeinfo(frame, context=1):
1569 """Get information about a frame or traceback object.

Callers 2

getframeinfoFunction · 0.70

Calls 3

nextFunction · 0.85
co_positionsMethod · 0.80
isliceMethod · 0.80

Tested by

no test coverage detected