code: def win_encode(s):
      
      if isinstance(s, unicode):
          return s.encode(locale.getpreferredencoding(False))
      elif isinstance(s, bytes):
          return s
      elif s is not None:
          raise TypeError('Expected bytes or text, but got %r' % (s,))
docs: Encode unicodes for process arguments on Windows.