Skip to content

create_frame

Copied from https://naleraphael.github.io/blog/posts/devlog_create_a_builtin_frame_object/

create_frame(code)

Creates a new frame object from a code object.

Source code in lineapy/exceptions/create_frame.py
24
25
26
27
28
29
30
31
32
33
34
35
36
def create_frame(code: CodeType) -> FrameType:
    """
    Creates a new frame object from a code object.
    """

    return ctypes.pythonapi.PyFrame_New(
        ctypes.pythonapi.PyThreadState_Get(),  # thread state
        ctypes.cast(id(code), P_MEM_TYPE),  # a code object
        # Make sure not to set __file__ in the globals,
        # or else ipython will look at it and change the file name
        {},  # a dict of globals
        {},  # a dict of locals
    )

Was this helpful?

Help us improve docs with your feedback!