<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def block_specification_to_number(block: BlockSpecification, web3: Web3) -> BlockNumber: """ Converts a block specification to an actual block number """

    if isinstance(block, str):
        msg = f"string block specification can't contain {block}"
        assert block in ('latest', 'pending'), msg
        number = web3.eth.getBlock(block)['number']
    elif isinstance(block, T_BlockHash):
        number = web3.eth.getBlock(block)['number']
    elif isinstance(block, T_BlockNumber):
        number = block
    else:
        if __debug__:
            raise AssertionError(f'Unknown type {type(block)} given for block specification')

    return BlockNumber(number)