def hex_to_sha(hex):
 assert (len(hex) == 40), ('Incorrect length of hexsha: %s' % hex)
 try:
  return binascii.unhexlify(hex)
 except TypeError as exc:
  if (not isinstance(hex, bytes)):
   raise
  raise ValueError(exc.args[0])

def hex_to_sha ( hex ) : assert ( len ( hex ) == 40 ) , ( 'Incorrect length of hexsha: %s' % hex ) try : return binascii . unhexlify ( hex ) except TypeError as exc : if ( not isinstance ( hex , bytes ) ) : raise raise ValueError ( exc . args [ 0 ] )
takes a hex sha and returns a binary sha .