comparison mercurial/posix.py @ 48885:a2c59b361e0f

posix: delete Python 2 posixfile() The comment no longer makes sense since the stdlib open() behaves the way we want on Python 3. So it was removed. Differential Revision: https://phab.mercurial-scm.org/D12288
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 03 Mar 2022 08:04:33 -0800
parents 6000f5b25c9b
children 642e31cb55f0
comparison
equal deleted inserted replaced
48884:7f5e91cdebcd 48885:a2c59b361e0f
57 expandglobs = False 57 expandglobs = False
58 58
59 umask = os.umask(0) 59 umask = os.umask(0)
60 os.umask(umask) 60 os.umask(umask)
61 61
62 if not pycompat.ispy3: 62 posixfile = open
63
64 def posixfile(name, mode='r', buffering=-1):
65 fp = open(name, mode=mode, buffering=buffering)
66 # The position when opening in append mode is implementation defined, so
67 # make it consistent by always seeking to the end.
68 if 'a' in mode:
69 fp.seek(0, os.SEEK_END)
70 return fp
71
72
73 else:
74 # The underlying file object seeks as required in Python 3:
75 # https://github.com/python/cpython/blob/v3.7.3/Modules/_io/fileio.c#L474
76 posixfile = open
77 63
78 64
79 def split(p): 65 def split(p):
80 """Same as posixpath.split, but faster 66 """Same as posixpath.split, but faster
81 67