Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 30639:d524c88511a7
py3: replace os.name with pycompat.osname (part 1 of 2)
os.name returns unicodes on py3 and we have pycompat.osname which returns
bytes. This series of 2 patches will change every ocurrence of os.name with
pycompat.osname.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 19 Dec 2016 00:16:52 +0530 |
parents | 344e68882cd3 |
children | e995f00a9e9a |
comparison
equal
deleted
inserted
replaced
30638:1c5cbf28f007 | 30639:d524c88511a7 |
---|---|
61 urlerr = pycompat.urlerr | 61 urlerr = pycompat.urlerr |
62 urlparse = pycompat.urlparse | 62 urlparse = pycompat.urlparse |
63 urlreq = pycompat.urlreq | 63 urlreq = pycompat.urlreq |
64 xmlrpclib = pycompat.xmlrpclib | 64 xmlrpclib = pycompat.xmlrpclib |
65 | 65 |
66 if os.name == 'nt': | 66 if pycompat.osname == 'nt': |
67 from . import windows as platform | 67 from . import windows as platform |
68 stdout = platform.winstdout(pycompat.stdout) | 68 stdout = platform.winstdout(pycompat.stdout) |
69 else: | 69 else: |
70 from . import posix as platform | 70 from . import posix as platform |
71 | 71 |
236 return sliceable[offset:] | 236 return sliceable[offset:] |
237 else: | 237 else: |
238 def buffer(sliceable, offset=0): | 238 def buffer(sliceable, offset=0): |
239 return memoryview(sliceable)[offset:] | 239 return memoryview(sliceable)[offset:] |
240 | 240 |
241 closefds = os.name == 'posix' | 241 closefds = pycompat.osname == 'posix' |
242 | 242 |
243 _chunksize = 4096 | 243 _chunksize = 4096 |
244 | 244 |
245 class bufferedinputpipe(object): | 245 class bufferedinputpipe(object): |
246 """a manually buffered input pipe | 246 """a manually buffered input pipe |
1173 t = n[-1] | 1173 t = n[-1] |
1174 if t in '. ' and n not in '..': | 1174 if t in '. ' and n not in '..': |
1175 return _("filename ends with '%s', which is not allowed " | 1175 return _("filename ends with '%s', which is not allowed " |
1176 "on Windows") % t | 1176 "on Windows") % t |
1177 | 1177 |
1178 if os.name == 'nt': | 1178 if pycompat.osname == 'nt': |
1179 checkosfilename = checkwinfilename | 1179 checkosfilename = checkwinfilename |
1180 else: | 1180 else: |
1181 checkosfilename = platform.checkosfilename | 1181 checkosfilename = platform.checkosfilename |
1182 | 1182 |
1183 def makelock(info, pathname): | 1183 def makelock(info, pathname): |
1392 return osutil.isgui() | 1392 return osutil.isgui() |
1393 else: | 1393 else: |
1394 # pure build; use a safe default | 1394 # pure build; use a safe default |
1395 return True | 1395 return True |
1396 else: | 1396 else: |
1397 return os.name == "nt" or encoding.environ.get("DISPLAY") | 1397 return pycompat.osname == "nt" or encoding.environ.get("DISPLAY") |
1398 | 1398 |
1399 def mktempcopy(name, emptyok=False, createmode=None): | 1399 def mktempcopy(name, emptyok=False, createmode=None): |
1400 """Create a temporary file with the same contents from name | 1400 """Create a temporary file with the same contents from name |
1401 | 1401 |
1402 The permission bits are copied from the original file. | 1402 The permission bits are copied from the original file. |