[PATCH 1 of 2] prevent transient leaks of file handle by using new helper functions

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sun May 1 10:56:24 CDT 2011


On 1 May 2011, at 12:32, Dan Villiom Podlaski Christiansen wrote:

> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
> # Date 1304243231 -7200
> # Node ID ddebfda06862e0cb975ccf69a12c5a27214ad41f
> # Parent  52dadaaebd0f0f3de85a3e2d5829a4ac1399f1f9
> 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(...)

Note to self:

Matt requested that I change this, so that the functions look like this:

opener.read(path)
opener.write(path, text)
opener.append(path, text)

readfile(path)
writefile(path, text)
appendfile(path, text)

In order to do this, we need to convert a couple of files (requires  
and sharedpath) to be read and written in binary mode. We shouldn't  
use text mode anymore.

(I'm getting a bit tired so this is mainly a note to myself to make  
sure I remember it. I figured I'd tell the world while at it, just in  
case…)

--

Dan Villiom Podlaski Christiansen
danchr at gmail.com



More information about the Mercurial-devel mailing list