def record_context(self, space, frame):
        """Record a __context__ for this exception from the current
        frame if one exists.

        __context__ is otherwise lazily determined from the
        traceback. However the current frame.last_exception must be
        checked for a __context__ before this OperationError overwrites
        it (making the previous last_exception unavailable later on).
        """
        last_exception = frame.last_exception
        if (last_exception is not None and not frame.hide() or
            last_exception is get_cleared_operation_error(space)):
            # normalize w_value so setup_context can check for cycles
            self.normalize_exception(space)
            w_value = self.get_w_value(space)
            w_last = last_exception.get_w_value(space)
            w_context = setup_context(space, w_value, w_last, lazy=True)
            space.setattr(w_value, space.wrap('__context__'), w_context)