code: def set_linetrace_on_frame(f, localtrace=None):
      
      traceptr, _, _ = get_frame_pointers(f)
      if localtrace is not None:
          # Need to incref to avoid the frame causing a double-delete
          ctypes.pythonapi.Py_IncRef(localtrace)
          # Not sure if this is the best way to do this, but it works.
          addr = id(localtrace)
      else:
          addr = 0
  
      traceptr.contents = ctypes.py_object.from_address(addr)
docs: Non-portable function to modify linetracing.
  
      Remember to enable global tracing with :py:func:`sys.settrace`, otherwise no
      effect!