diff --git a/gclient_utils.py b/gclient_utils.py index 4b858ceee..b645806e6 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -1097,13 +1097,13 @@ def RunEditor(content, git, git_editor=None): if '\r' in content: print( '!! Please remove \\r from your change description !!', file=sys.stderr) - fileobj = os.fdopen(file_handle, 'w') + fileobj = os.fdopen(file_handle, 'wb') # Still remove \r if present. content = re.sub('\r?\n', '\n', content) # Some editors complain when the file doesn't end in \n. if not content.endswith('\n'): content += '\n' - fileobj.write(content) + fileobj.write(content.encode('utf-8')) fileobj.close() try: diff --git a/git_cl.py b/git_cl.py index 3dd546ffe..a12483ac9 100755 --- a/git_cl.py +++ b/git_cl.py @@ -164,8 +164,8 @@ def DieWithError(message, change_desc=None): def SaveDescriptionBackup(change_desc): backup_path = os.path.join(DEPOT_TOOLS, DESCRIPTION_BACKUP_FILE) print('\nsaving CL description to %s\n' % backup_path) - with open(backup_path, 'w') as backup_file: - backup_file.write(change_desc.description) + with open(backup_path, 'wb') as backup_file: + backup_file.write(change_desc.description.encode('utf-8')) def GetNoGitPagerEnv():