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.
--- 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)