def decode_dict_keys_to_str(src):
 if ((not six.PY3) or (not isinstance(src, dict))):
  return src
 output = {}
 for (key, val) in six.iteritems(src):
  if isinstance(key, bytes):
   try:
    key = key.decode()
   except UnicodeError:
    pass
  output[key] = val
 return output

def decode_dict_keys_to_str ( src ) : if ( ( not six . PY3 ) or ( not isinstance ( src , dict ) ) ) : return src output = { } for ( key , val ) in six . iteritems ( src ) : if isinstance ( key , bytes ) : try : key = key . decode ( ) except UnicodeError : pass output [ key ] = val return output
convert top level keys from bytes to strings if possible .