# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1486996598 -19800 # Node ID 48dea083f66d6cb7bbb778fa87e7374833399100 # Parent 78de43ab585f76122520562d0761d46ced2fd5d7 py3: convert the mode argument of os.fdopen to unicodes (1 of 2) os.fdopen() does not accepts bytes as its second argument which represent the mode in which the file is to be opened. This patch makes sure unicodes are passed in py3 by using pycompat.sysstr(). diff -r 78de43ab585f -r 48dea083f66d mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/bundlerepo.py Mon Feb 13 20:06:38 2017 +0530 @@ -272,7 +272,7 @@ suffix=".hg10un") self.tempfile = temp - with os.fdopen(fdtemp, 'wb') as fptemp: + with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp: fptemp.write(header) while True: chunk = read(2**18) diff -r 78de43ab585f -r 48dea083f66d mercurial/chgserver.py --- a/mercurial/chgserver.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/chgserver.py Mon Feb 13 20:06:38 2017 +0530 @@ -287,9 +287,9 @@ _iochannels = [ # server.ch, ui.fp, mode - ('cin', 'fin', 'rb'), - ('cout', 'fout', 'wb'), - ('cerr', 'ferr', 'wb'), + ('cin', 'fin', pycompat.sysstr('rb')), + ('cout', 'fout', pycompat.sysstr('wb')), + ('cerr', 'ferr', pycompat.sysstr('wb')), ] class chgcmdserver(commandserver.server): diff -r 78de43ab585f -r 48dea083f66d mercurial/commandserver.py --- a/mercurial/commandserver.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/commandserver.py Mon Feb 13 20:06:38 2017 +0530 @@ -304,8 +304,8 @@ ui.flush() newfiles = [] nullfd = os.open(os.devnull, os.O_RDWR) - for f, sysf, mode in [(ui.fin, util.stdin, 'rb'), - (ui.fout, util.stdout, 'wb')]: + for f, sysf, mode in [(ui.fin, util.stdin, pycompat.sysstr('rb')), + (ui.fout, util.stdout, pycompat.sysstr('wb'))]: if f is sysf: newfd = os.dup(f.fileno()) os.dup2(nullfd, f.fileno()) diff -r 78de43ab585f -r 48dea083f66d mercurial/filemerge.py --- a/mercurial/filemerge.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/filemerge.py Mon Feb 13 20:06:38 2017 +0530 @@ -585,7 +585,7 @@ pre = "%s~%s." % (os.path.basename(fullbase), prefix) (fd, name) = tempfile.mkstemp(prefix=pre, suffix=ext) data = repo.wwritedata(ctx.path(), ctx.data()) - f = os.fdopen(fd, "wb") + f = os.fdopen(fd, pycompat.sysstr("wb")) f.write(data) f.close() return name diff -r 78de43ab585f -r 48dea083f66d mercurial/httppeer.py --- a/mercurial/httppeer.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/httppeer.py Mon Feb 13 20:06:38 2017 +0530 @@ -20,6 +20,7 @@ bundle2, error, httpconnection, + pycompat, statichttprepo, url, util, @@ -327,7 +328,7 @@ try: # dump bundle to disk fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") - fh = os.fdopen(fd, "wb") + fh = os.fdopen(fd, pycompat.sysstr("wb")) d = fp.read(4096) while d: fh.write(d) diff -r 78de43ab585f -r 48dea083f66d mercurial/patch.py --- a/mercurial/patch.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/patch.py Mon Feb 13 20:06:38 2017 +0530 @@ -34,6 +34,7 @@ mail, mdiff, pathutil, + pycompat, scmutil, similar, util, @@ -209,7 +210,7 @@ data = {} fd, tmpname = tempfile.mkstemp(prefix='hg-patch-') - tmpfp = os.fdopen(fd, 'w') + tmpfp = os.fdopen(fd, pycompat.sysstr('w')) try: msg = email.Parser.Parser().parse(fileobj) @@ -1055,7 +1056,7 @@ ncpatchfp = None try: # Write the initial patch - f = os.fdopen(patchfd, "w") + f = os.fdopen(patchfd, pycompat.sysstr("w")) chunk.header.write(f) chunk.write(f) f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) diff -r 78de43ab585f -r 48dea083f66d mercurial/wireproto.py --- a/mercurial/wireproto.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/wireproto.py Mon Feb 13 20:06:38 2017 +0530 @@ -26,6 +26,7 @@ exchange, peer, pushkey as pushkeymod, + pycompat, streamclone, util, ) @@ -961,7 +962,7 @@ # write bundle data to temporary file because it can be big fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') - fp = os.fdopen(fd, 'wb+') + fp = os.fdopen(fd, pycompat.sysstr('wb+')) r = 0 try: proto.getfile(fp) diff -r 78de43ab585f -r 48dea083f66d mercurial/worker.py --- a/mercurial/worker.py Thu Feb 09 15:20:41 2017 -0500 +++ b/mercurial/worker.py Mon Feb 13 20:06:38 2017 +0530 @@ -157,7 +157,7 @@ os._exit(0) pids.add(pid) os.close(wfd) - fp = os.fdopen(rfd, 'rb', 0) + fp = os.fdopen(rfd, pycompat.sysstr('rb'), 0) def cleanup(): signal.signal(signal.SIGINT, oldhandler) waitforworkers()