Mercurial > public > mercurial-scm > hg-stable
comparison contrib/check-code.py @ 13400:14f3795a5ed7
explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 24 Dec 2010 15:23:01 +0100 |
parents | 4b07578967e6 |
children | 43b3b761d9d1 |
comparison
equal
deleted
inserted
replaced
13399:eff102facb15 | 13400:14f3795a5ed7 |
---|---|
246 result = True | 246 result = True |
247 for name, match, filters, pats in checks: | 247 for name, match, filters, pats in checks: |
248 fc = 0 | 248 fc = 0 |
249 if not re.match(match, f): | 249 if not re.match(match, f): |
250 continue | 250 continue |
251 pre = post = open(f).read() | 251 fp = open(f) |
252 pre = post = fp.read() | |
253 fp.close() | |
252 if "no-" + "check-code" in pre: | 254 if "no-" + "check-code" in pre: |
253 break | 255 break |
254 for p, r in filters: | 256 for p, r in filters: |
255 post = re.sub(p, r, post) | 257 post = re.sub(p, r, post) |
256 # print post # uncomment to show filtered version | 258 # print post # uncomment to show filtered version |