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

Function _get_code_position

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

Source from the content-addressed store, hash-verified

1583 return _get_code_position(code, instruction_index)
1584
1585def _get_code_position(code, instruction_index):
1586 if instruction_index < 0:
1587 return (None, None, None, None)
1588 positions_gen = code.co_positions()
1589 # The nth entry in code.co_positions() corresponds to instruction (2*n)th since Python 3.10+
1590 return next(itertools.islice(positions_gen, instruction_index // 2, None))
1591
1592def getframeinfo(frame, context=1):
1593 """Get information about a frame or traceback object.

Callers 2

getframeinfoFunction · 0.70

Calls 1

isliceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…