def _make_c_string_check(string):
 if isinstance(string, bytes):
  if ('\x00' in string):
   raise InvalidDocument('BSON keys / regex patterns must not contain a NUL character')
  try:
   _utf_8_decode(string, None, True)
   return (string + '\x00')
  except UnicodeError:
   raise InvalidStringData(('strings in documents must be valid UTF-8: %r' % string))
 else:
  if ('\x00' in string):
   raise InvalidDocument('BSON keys / regex patterns must not contain a NUL character')
  return (_utf_8_encode(string)[0] + '\x00')

def _make_c_string_check ( string ) : if isinstance ( string , bytes ) : if ( '\x00' in string ) : raise InvalidDocument ( 'BSON keys / regex patterns must not contain a NUL character' ) try : _utf_8_decode ( string , None , True ) return ( string + '\x00' ) except UnicodeError : raise InvalidStringData ( ( 'strings in documents must be valid UTF-8: %r' % string ) ) else : if ( '\x00' in string ) : raise InvalidDocument ( 'BSON keys / regex patterns must not contain a NUL character' ) return ( _utf_8_encode ( string ) [ 0 ] + '\x00' )
make a c string .