=== modified file 'python/tests/Makefile.am'
--- old/python/tests/Makefile.am	2008-03-12 09:32:04 +0000
+++ new/python/tests/Makefile.am	2008-08-29 00:18:21 +0000
@@ -46,7 +46,8 @@
     validSchemas.py \
     validRNG.py \
     compareNodes.py \
-    xpathns.py
+    xpathns.py \
+    xpathleak.py
 
 XMLS=		\
     tst.xml	\

=== added file 'python/tests/xpathleak.py'
--- old/python/tests/xpathleak.py	1970-01-01 00:00:00 +0000
+++ new/python/tests/xpathleak.py	2008-08-29 00:18:21 +0000
@@ -0,0 +1,25 @@
+import sys, libxml2
+
+libxml2.debugMemory(True)
+
+doc = libxml2.parseDoc("<fish/>")
+ctxt = doc.xpathNewContext()
+ctxt.setContextNode(doc)
+for expr in (":false()","bad:()","bad(:)",":bad(:)","bad:(:)","bad:bad(:)"):
+	try:
+		ctxt.xpathEval(expr)
+	except libxml2.xpathError, e:
+		print >>sys.stderr, expr, "xpathError raised:", e
+	else:
+		print "Unexpectedly legal expression:", expr
+ctxt.xpathFreeContext()
+doc.freeDoc()
+
+libxml2.cleanupParser()
+leakedbytes = libxml2.debugMemory(True)
+if leakedbytes == 0:
+	print "OK"
+else:
+	print "Memory leak", leakedbytes, "bytes"
+	# drop file to .memdump file in cwd, but won't work if not compiled in
+	libxml2.dumpMemory()

