On 5/4/07, David Glasser <glasser@mit.edu> wrote:
> On 5/4/07, djames@tigris.org <djames@tigris.org> wrote:
> > (ClientURI.join, ClientURI.dirname, ClientURI.longest_ancestor):
> > Move pool to a local variable so that it will still be alive when
> > the function returns.
>
> > def join(self, uri):
> > """Join this URI and the specified relative URI,
> > adding a slash if necessary."""
> > - return ClientURI(svn_path_join(self, uri, Pool()))
> > + pool = Pool()
> > + return ClientURI(svn_path_join(self, uri, pool))
>
> I am not an expert on the internals of Python, but... is that really
> how Python GC works? Something referred to only in a local can't get
> GCed after the function returns?
My log message wasn't quite clear, so I've updated it to be more clear.
Local variables are garbage collected when the function returns, but,
if you pass in an anonymous pool to 'svn_path_join', the anonymous
pool will get garbage collected before the ClientURI constructor even
has a chance to process the return value. This is bad.
To fix this, I moved pool to a local variable, and updated the
ClientURI constructor to convert its input argument to a regular
Python string so that it is safe to destroy the pool after the
ClientURI is created.
Hope this helps,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 4 14:52:13 2007