code: def convert(word):
      
      if six.PY2:
          if isinstance(word, unicode):
              return word.encode('utf-8')
          else:
              return word.decode('utf-8').encode('utf-8') # make sure it is real utf8, otherwise complain
      else: # ==> Py3
          if isinstance(word, bytes):
              return word.decode('utf-8') # bytes must be in utf8
          return word
docs: This method converts given `word` to UTF-8 encoding and `bytes` type for the
         SWIG wrapper.