Encoding pathnames with sys.getfilesystemencoding is always wrong.

On Windows this encodes with the current codepage, which often fails for characters not in the codepage.

On Windows, FS functions accept 'unicode' and encode as UTF-16 for WinAPI
On Mac, FS functions accept 'unicode' and encode as UTF-8 for FS API
On Linux, filenames are byte strings and encoding is only a convention. FS functions encode 'unicode' according to locale. On Linux, it is possible to have files whose names cannot be decoded in any character set!
This commit is contained in:
David Vierra 2015-05-13 21:36:31 -10:00
parent d330a22453
commit 4c6603371f

View File

@ -159,7 +159,7 @@ this way.
self.versions.append(version)
def jarfileForVersion(self, v):
return os.path.join(self.cacheDir, v, "minecraft_server.jar").encode(sys.getfilesystemencoding())
return os.path.join(self.cacheDir, v, "minecraft_server.jar")
def checksumForVersion(self, v):
jf = self.jarfileForVersion(v)
@ -506,9 +506,6 @@ class MCServerChunkGenerator(object):
level.saveChanges()
def runServer(self, startingDir):
if isinstance(startingDir, unicode):
startingDir = startingDir.encode(sys.getfilesystemencoding())
return self._runServer(startingDir, self.serverJarFile)
lowMemory = False