Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.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 | a520aefb96f1 |
children | bf855efe5664 |
comparison
equal
deleted
inserted
replaced
30923:78de43ab585f | 30924:48dea083f66d |
---|---|
18 from .node import nullid | 18 from .node import nullid |
19 from . import ( | 19 from . import ( |
20 bundle2, | 20 bundle2, |
21 error, | 21 error, |
22 httpconnection, | 22 httpconnection, |
23 pycompat, | |
23 statichttprepo, | 24 statichttprepo, |
24 url, | 25 url, |
25 util, | 26 util, |
26 wireproto, | 27 wireproto, |
27 ) | 28 ) |
325 fp_ = None | 326 fp_ = None |
326 filename = None | 327 filename = None |
327 try: | 328 try: |
328 # dump bundle to disk | 329 # dump bundle to disk |
329 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") | 330 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") |
330 fh = os.fdopen(fd, "wb") | 331 fh = os.fdopen(fd, pycompat.sysstr("wb")) |
331 d = fp.read(4096) | 332 d = fp.read(4096) |
332 while d: | 333 while d: |
333 fh.write(d) | 334 fh.write(d) |
334 d = fp.read(4096) | 335 d = fp.read(4096) |
335 fh.close() | 336 fh.close() |