diff -r 86ba6e3eba4e -r 1fbbb8e83392 mercurial/util.py --- a/mercurial/util.py Mon Mar 05 12:31:08 2018 -0500 +++ b/mercurial/util.py Sun Mar 04 18:21:16 2018 -0500 @@ -1685,7 +1685,8 @@ except AttributeError: # no symlink in os pass - ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL) + flags = os.O_CREAT | os.O_WRONLY | os.O_EXCL | getattr(os, 'O_BINARY', 0) + ld = os.open(pathname, flags) os.write(ld, info) os.close(ld) @@ -1697,7 +1698,7 @@ raise except AttributeError: # no symlink in os pass - fp = posixfile(pathname) + fp = posixfile(pathname, 'rb') r = fp.read() fp.close() return r