def locals(space):
    """Return a dictionary containing the current scope's local variables.
Note that this may be the real dictionary of local variables, or a copy."""
    ec = space.getexecutioncontext()
    return ec.gettopframe_nohidden().getdictscope()