def binary_replace(data, a, b):
 if on_win:
  if has_pyzzer_entry_point(data):
   return replace_pyzzer_entry_point_shebang(data, a, b)
  else:
   return data
 def replace(match):
  occurances = match.group().count(a)
  padding = ((len(a) - len(b)) * occurances)
  if (padding < 0):
   raise _PaddingError
  return (match.group().replace(a, b) + ('\x00' * padding))
 original_data_len = len(data)
 pat = re.compile((re.escape(a) + '([^\x00]*?)\x00'))
 data = pat.sub(replace, data)
 assert (len(data) == original_data_len)
 return data

def binary_replace ( data , a , b ) : if on_win : if has_pyzzer_entry_point ( data ) : return replace_pyzzer_entry_point_shebang ( data , a , b ) else : return data def replace ( match ) : occurances = match . group ( ) . count ( a ) padding = ( ( len ( a ) - len ( b ) ) * occurances ) if ( padding < 0 ) : raise _PaddingError return ( match . group ( ) . replace ( a , b ) + ( '\x00' * padding ) ) original_data_len = len ( data ) pat = re . compile ( ( re . escape ( a ) + '([^\x00]*?)\x00' ) ) data = pat . sub ( replace , data ) assert ( len ( data ) == original_data_len ) return data
perform a binary replacement of data .