changeset 31532:713e984bec91

ui: convert to/from Unicode on Python 3 in ui.editor() I considered making this I/O be done in terms of bytes, but that would cause an observable regression for Windows users, as non-binary-mode open does EOL conversion there. There are probably new encoding dragons lurking here, so we may want to switch to using binary mode and doing EOL conversion ourselves.
author Augie Fackler <augie@google.com>
date Sun, 19 Mar 2017 01:38:10 -0400
parents 326bca5477d0
children 28f00d07e2ee
files mercurial/ui.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sun Mar 19 01:12:03 2017 -0400
+++ b/mercurial/ui.py	Sun Mar 19 01:38:10 2017 -0400
@@ -1196,7 +1196,7 @@
                                       dir=rdir)
         try:
             f = os.fdopen(fd, pycompat.sysstr("w"))
-            f.write(text)
+            f.write(encoding.strfromlocal(text))
             f.close()
 
             environ = {'HGUSER': user}
@@ -1219,7 +1219,7 @@
                         blockedtag='editor')
 
             f = open(name)
-            t = f.read()
+            t = encoding.strtolocal(f.read())
             f.close()
         finally:
             os.unlink(name)