def parse_ieee_block_header(block):
    """
    Parse the header of a IEEE block.
    Definite Length Arbitrary Block:
    #<header_length><data_length><data>
    The header_length specifies the size of the data_length field.
    And the data_length field specifies the size of the data.
    Indefinite Length Arbitrary Block:
    #0<data>
    :param block: IEEE block.
    :type block: bytes | bytearray
    :return: (offset, data_length)
    :rtype: (int, int)
    """
    # Function copied from pyVISA
    # copyright: 2014 by PyVISA Authors, see AUTHORS for more details.
    # license: MIT, see pyVISA LICENSE for more details.


    begin = block.find(b'#')
    if begin < 0:
        raise ValueError("Could not find hash sign (#) indicating the start of"
                         " the block.")

    try:
        # int(block[begin+1]) != int(block[begin+1:begin+2]) in Python 3
        header_length = int(block[begin + 1:begin + 2])
    except ValueError:
        header_length = 0
    offset = begin + 2 + header_length

    if header_length > 0:
        # #3100DATA
        # 012345
        data_length = int(block[begin + 2:offset])
    else:
        # #0DATA
        # 012
        data_length = len(block) - offset - 1

    return offset, data_length