[lxml-dev] Leaking tracebacks
Christian Heimes
lists at cheimes.de
Mon Nov 17 02:16:15 CET 2008
Christian Heimes wrote:
> import sys
> import pkg_resources
> pkg_resources.require("lxml==%s" % sys.argv[1])
>
> from lxml import etree
>
> class SampleException(Exception):
> pass
>
> def test():
> print "lxml: %s, %s, %s" % (etree.LXML_VERSION,
> etree.LIBXML_VERSION,
> etree.LIBXSLT_VERSION)
> print "SampleException start: %i" % sys.getrefcount(SampleException)
> for i in range(1000):
> try:
> raise SampleException
> except Exception, err:
# this removes the ref leak
sys.exc_clear()
> el = etree.Element("test")
> if i == 999:
> print "exception: %i" % sys.getrefcount(err)
> print "SampleException stop: %i" % sys.getrefcount(SampleException)
>
> if __name__ == "__main__":
hristian
More information about the lxml-dev
mailing list