def _assert_real_val(msg, name, expected):
    """Verify that attr name of msg equals expected.

    protobuf messages are subject to precision loss for floats if the
    C backend is used. This function raises an assertion error if the
    message attr value isn't equal to the expected value).
    """
    actual = getattr(msg, name)
    if actual != expected:
        raise AssertionError(
            """bad protobuf value for '%s': expected %s but got %s
Try setting env PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python"""
             % (name, expected, actual))
