zopefoundation / zope.publisher

Map requests from HTTP/WebDAV clients, web browsers, XML-RPC and FTP clients onto Python objects
Other
3 stars 13 forks source link

Avoid traceback reference cycle in publish #63

Closed cjwatson closed 3 years ago

cjwatson commented 3 years ago

sys.exc_info() called from publish returns a tuple containing the exception's traceback object, which has a reference to the publish frame. Storing that in a local variable creates a reference cycle. Clear that variable in a finally block to avoid this.

I don't have a test for this, nor much of an idea of how to write one. I noticed it while auditing an application for reference cycle problems of this kind after finding that it had severe memory leaks on Python 3; this probably doesn't contribute much to that, but it seems worth fixing anyway.

cjwatson commented 3 years ago

The docs failure is, I presume, fixed by #62.

Indeed, and rebasing after that was merged has fixed that.