[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r24932 - branches/ctypes-python-bindings/csvn

From: David James <james_at_cs.toronto.edu>
Date: 2007-05-04 14:52:02 CEST

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,


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

This is an archived mail posted to the Subversion Dev mailing list.