Mercurial > public > mercurial-scm > hg
comparison mercurial/commandserver.py @ 30924:48dea083f66d
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().
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 13 Feb 2017 20:06:38 +0530 |
parents | b1b36c6499c2 |
children | c8b9943c07eb |
comparison
equal
deleted
inserted
replaced
30923:78de43ab585f | 30924:48dea083f66d |
---|---|
302 def _protectio(ui): | 302 def _protectio(ui): |
303 """ duplicates streams and redirect original to null if ui uses stdio """ | 303 """ duplicates streams and redirect original to null if ui uses stdio """ |
304 ui.flush() | 304 ui.flush() |
305 newfiles = [] | 305 newfiles = [] |
306 nullfd = os.open(os.devnull, os.O_RDWR) | 306 nullfd = os.open(os.devnull, os.O_RDWR) |
307 for f, sysf, mode in [(ui.fin, util.stdin, 'rb'), | 307 for f, sysf, mode in [(ui.fin, util.stdin, pycompat.sysstr('rb')), |
308 (ui.fout, util.stdout, 'wb')]: | 308 (ui.fout, util.stdout, pycompat.sysstr('wb'))]: |
309 if f is sysf: | 309 if f is sysf: |
310 newfd = os.dup(f.fileno()) | 310 newfd = os.dup(f.fileno()) |
311 os.dup2(nullfd, f.fileno()) | 311 os.dup2(nullfd, f.fileno()) |
312 f = os.fdopen(newfd, mode) | 312 f = os.fdopen(newfd, mode) |
313 newfiles.append(f) | 313 newfiles.append(f) |