Mercurial > public > mercurial-scm > hg
comparison mercurial/help.py @ 14168:135e244776f0
prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.
This implies:
- changing opener(...).read() calls to opener.read(...)
- changing opener(...).write() calls to opener.write(...)
- changing open(...).read(...) to util.readfile(...)
- changing open(...).write(...) to util.writefile(...)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 02 May 2011 10:11:18 +0200 |
parents | 0528b69f8db4 |
children | d5b525697ddb |
comparison
equal
deleted
inserted
replaced
14167:0e4753807c93 | 14168:135e244776f0 |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from i18n import gettext, _ | 8 from i18n import gettext, _ |
9 import sys, os | 9 import sys, os |
10 import extensions | 10 import extensions |
11 import util | |
11 | 12 |
12 | 13 |
13 def moduledoc(file): | 14 def moduledoc(file): |
14 '''return the top-level python documentation for the given file | 15 '''return the top-level python documentation for the given file |
15 | 16 |
77 docdir = os.path.join(base, dir, 'help') | 78 docdir = os.path.join(base, dir, 'help') |
78 if os.path.isdir(docdir): | 79 if os.path.isdir(docdir): |
79 break | 80 break |
80 | 81 |
81 path = os.path.join(docdir, topic + ".txt") | 82 path = os.path.join(docdir, topic + ".txt") |
82 doc = gettext(open(path).read()) | 83 doc = gettext(util.readfile(path)) |
83 for rewriter in helphooks.get(topic, []): | 84 for rewriter in helphooks.get(topic, []): |
84 doc = rewriter(topic, doc) | 85 doc = rewriter(topic, doc) |
85 return doc | 86 return doc |
86 | 87 |
87 return loader | 88 return loader |