Fix a few problems with setEntityLoader

1. Setting entity loader does not increment the refcount on the Python object
passed in. This works only if the object is not deleted. For example, the
following code results in segmentation fault in Python interpreter when
attempting to process any document:

[[[
def register_entity_loader():
    def entity_loader(URL, ID, ctxt):
        ...
    libxml2.setEntityLoader(entity_loader

register_entity_loader()
]]]

2. setEntityLoader() does not verify if the passed object is callable. If it
is not, current implementation attempts to call it anyway and failing that,
silently moves on to default entity loader. Attached patch makes
setEntityLoader raise ValueError exception if non-callable object is
passed.

3. In debug mode, pythonExternalEntityLoader() outputs the result object to
stderr, while the messages before and after the object (description + newline)
go to stdout. Attached patch makes them all go to stdout.
1 file changed
tree: b8f7e694aa0895286480c92832f91de67d02b8e6
  1. bakefile/
  2. doc/
  3. example/
  4. include/
  5. macos/
  6. optim/
  7. python/
  8. result/
  9. test/
  10. vms/
  11. VxWorks/
  12. win32/
  13. xstc/
  14. .gitignore
  15. acinclude.m4
  16. AUTHORS
  17. autogen.sh
  18. buf.c
  19. buf.h
  20. build_glob.py
  21. c14n.c
  22. catalog.c
  23. ChangeLog
  24. check-relaxng-test-suite.py
  25. check-relaxng-test-suite2.py
  26. check-xinclude-test-suite.py
  27. check-xml-test-suite.py
  28. check-xsddata-test-suite.py
  29. chvalid.c
  30. chvalid.def
  31. configure.in
  32. Copyright
  33. dbgen.pl
  34. dbgenattr.pl
  35. debugXML.c
  36. dict.c
  37. DOCBparser.c
  38. elfgcchack.h
  39. enc.h
  40. encoding.c
  41. entities.c
  42. error.c
  43. genChRanges.py
  44. gentest.py
  45. genUnicode.py
  46. global.data
  47. globals.c
  48. HACKING
  49. hash.c
  50. HTMLparser.c
  51. HTMLtree.c
  52. INSTALL.libxml2
  53. legacy.c
  54. libxml-2.0-uninstalled.pc.in
  55. libxml-2.0.pc.in
  56. libxml.3
  57. libxml.h
  58. libxml.m4
  59. libxml.spec.in
  60. libxml2.doap
  61. libxml2.syms
  62. list.c
  63. MAINTAINERS
  64. Makefile.am
  65. Makefile.tests
  66. Makefile.win
  67. nanoftp.c
  68. nanohttp.c
  69. NEWS
  70. parser.c
  71. parserInternals.c
  72. pattern.c
  73. README
  74. README.cvs-commits
  75. README.tests
  76. regressions.py
  77. regressions.xml
  78. relaxng.c
  79. rngparser.c
  80. runsuite.c
  81. runtest.c
  82. runxmlconf.c
  83. save.h
  84. SAX.c
  85. SAX2.c
  86. schematron.c
  87. testapi.c
  88. testAutomata.c
  89. testC14N.c
  90. testchar.c
  91. testdict.c
  92. testdso.c
  93. testHTML.c
  94. testlimits.c
  95. testModule.c
  96. testOOM.c
  97. testOOMlib.c
  98. testOOMlib.h
  99. testReader.c
  100. testrecurse.c
  101. testRegexp.c
  102. testRelax.c
  103. testSAX.c
  104. testSchemas.c
  105. testThreads.c
  106. testThreadsWin32.c
  107. testURI.c
  108. testXPath.c
  109. threads.c
  110. timsort.h
  111. TODO
  112. TODO_SCHEMAS
  113. tree.c
  114. trio.c
  115. trio.h
  116. triodef.h
  117. trionan.c
  118. trionan.h
  119. triop.h
  120. triostr.c
  121. triostr.h
  122. uri.c
  123. valid.c
  124. xinclude.c
  125. xlink.c
  126. xml2-config.1
  127. xml2-config.in
  128. xml2Conf.sh.in
  129. xmlcatalog.c
  130. xmlIO.c
  131. xmllint.c
  132. xmlmemory.c
  133. xmlmodule.c
  134. xmlreader.c
  135. xmlregexp.c
  136. xmlsave.c
  137. xmlschemas.c
  138. xmlschemastypes.c
  139. xmlstring.c
  140. xmlunicode.c
  141. xmlwriter.c
  142. xpath.c
  143. xpointer.c
  144. xzlib.c
  145. xzlib.h