Fix some Python 3 problems with bytes versus string

This commit is contained in:
Martin von Gagern
2015-03-31 16:40:12 +02:00
parent b634d55a8f
commit 44df6dcec5

4
emsdk
View File

@@ -313,7 +313,7 @@ def download_text_file(url, dstpath, download_even_if_exists=False):
fix_lineendings(os.path.join(emsdk_path(), filename)) fix_lineendings(os.path.join(emsdk_path(), filename))
def run_get_output(cmd, cwd=None): def run_get_output(cmd, cwd=None):
process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, env=os.environ.copy()) process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, env=os.environ.copy(), universal_newlines=True)
(stdout, stderr) = process.communicate() (stdout, stderr) = process.communicate()
return (process.returncode, stdout, stderr) return (process.returncode, stdout, stderr)
@@ -692,7 +692,7 @@ class Tool:
def __init__(self, data): def __init__(self, data):
# Convert the dictionary representation of the tool in 'data' to members of this class for convenience. # Convert the dictionary representation of the tool in 'data' to members of this class for convenience.
for key in data: for key in data:
if isinstance(data[key], str): if sys.version_info < (3,) and isinstance(data[key], str):
setattr(self, key, data[key].encode('Latin-1')) setattr(self, key, data[key].encode('Latin-1'))
else: else:
setattr(self, key, data[key]) setattr(self, key, data[key])