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