##// END OF EJS Templates
cleanup: fix some latent open(path).read() et al calls we previously missed...
Augie Fackler -
r36966:0585337e default
parent child Browse files
Show More
@@ -104,7 +104,8 b' def docstrings(path):'
104 104 """
105 105 mod = importpath(path)
106 106 if not path.startswith('mercurial/') and mod.__doc__:
107 src = open(path).read()
107 with open(path) as fobj:
108 src = fobj.read()
108 109 lineno = 1 + offset(src, mod.__doc__, path, 7)
109 110 print(poentry(path, lineno, mod.__doc__))
110 111
@@ -143,7 +144,8 b' def docstrings(path):'
143 144
144 145
145 146 def rawtext(path):
146 src = open(path).read()
147 with open(path) as f:
148 src = f.read()
147 149 print(poentry(path, 1, src))
148 150
149 151
@@ -4,9 +4,10 b' import cffi'
4 4 import os
5 5
6 6 ffi = cffi.FFI()
7 ffi.set_source("mercurial.cffi._bdiff",
8 open(os.path.join(os.path.join(os.path.dirname(__file__), '..'),
9 'bdiff.c')).read(), include_dirs=['mercurial'])
7 with open(os.path.join(os.path.join(os.path.dirname(__file__), '..'),
8 'bdiff.c')) as f:
9 ffi.set_source("mercurial.cffi._bdiff",
10 f.read(), include_dirs=['mercurial'])
10 11 ffi.cdef("""
11 12 struct bdiff_line {
12 13 int hash, n, e;
@@ -6,8 +6,9 b' import os'
6 6 ffi = cffi.FFI()
7 7 mpatch_c = os.path.join(os.path.join(os.path.dirname(__file__), '..',
8 8 'mpatch.c'))
9 ffi.set_source("mercurial.cffi._mpatch", open(mpatch_c).read(),
10 include_dirs=["mercurial"])
9 with open(mpatch_c) as f:
10 ffi.set_source("mercurial.cffi._mpatch", f.read(),
11 include_dirs=["mercurial"])
11 12 ffi.cdef("""
12 13
13 14 struct mpatch_frag {
@@ -264,7 +264,8 b' def checklink(path):'
264 264 # already exists.
265 265 target = 'checklink-target'
266 266 try:
267 open(os.path.join(cachedir, target), 'w').close()
267 fullpath = os.path.join(cachedir, target)
268 open(fullpath, 'w').close()
268 269 except IOError as inst:
269 270 if inst[0] == errno.EACCES:
270 271 # If we can't write to cachedir, just pretend
@@ -61,7 +61,8 b' def visit(opts, filenames, outfile):'
61 61 if opts.type:
62 62 facts.append(b'file')
63 63 if any((opts.hexdump, opts.dump, opts.md5, opts.sha1, opts.sha256)):
64 content = open(f, 'rb').read()
64 with open(f, 'rb') as fobj:
65 content = fobj.read()
65 66 elif islink:
66 67 if opts.type:
67 68 facts.append(b'link')
General Comments 0
You need to be logged in to leave comments. Login now