UnicodeDecodeError when using socket.gethostname() result
问题 Some of my users report that the following code may raise a UnicodeDecodeError when the hostname contains non-ascii characters (however I haven't been able to replicate this on my Windows Vista machine): self.path = path self.lock_file = os.path.abspath(path) + ".lock" self.hostname = socket.gethostname() self.pid = os.getpid() dirname = os.path.dirname(self.lock_file) self.unique_name = os.path.join(dirname, "%s.%s" % (self.hostname, self.pid)) The last part of the traceback is: File