4 libxml2.debugMemory(True)
6 expect="""--> Invalid expression
7 --> xmlXPathEval: evaluation failed
9 --> xmlXPathEval: evaluation failed
10 --> Invalid expression
11 --> xmlXPathEval: evaluation failed
12 --> Invalid expression
13 --> xmlXPathEval: evaluation failed
14 --> Invalid expression
15 --> xmlXPathEval: evaluation failed
16 --> Invalid expression
17 --> xmlXPathEval: evaluation failed
18 --> Invalid expression
19 --> xmlXPathEval: evaluation failed
20 --> Invalid expression
21 --> xmlXPathEval: evaluation failed
22 --> Invalid expression
23 --> xmlXPathEval: evaluation failed
24 --> Invalid expression
25 --> xmlXPathEval: evaluation failed
28 def callback(ctx, str):
31 err = err + "%s %s" % (ctx, str)
33 libxml2.registerErrorHandler(callback, "-->")
35 doc = libxml2.parseDoc("<fish/>")
36 ctxt = doc.xpathNewContext()
37 ctxt.setContextNode(doc)
39 ":false()", "bad:()", "bad(:)", ":bad(:)", "bad:(:)", "bad:bad(:)",
40 "a:/b", "/c:/d", "//e:/f", "g://h"
45 except libxml2.xpathError:
48 print("Unexpectedly legal expression:", expr)
49 ctxt.xpathFreeContext()
54 print("received %s" %(err))
55 print("expected %s" %(expect))
58 libxml2.cleanupParser()
59 leakedbytes = libxml2.debugMemory(True)
63 print("Memory leak", leakedbytes, "bytes")
64 # drop file to .memdump file in cwd, but won't work if not compiled in