code: def _to_str(s):
      
      if sys.version_info[0] == 2 and not isinstance(s, str):
          # Assume it's Unicode, as that's what the PEP says
          # should be provided.
          return s.encode(sys.getfilesystemencoding())
      return s
docs: Convert a filename to a string (on Python 2, explicitly
      a byte string, not Unicode) as distutils checks for the
      exact type str.