mod_python and xml.dom.minidom

dpapathanasiou denis.papathanasiou at gmail.com
Fri May 8 19:36:06 EDT 2009


I wrote a python script called xml_utils.py which parses xml using
minidom.

It works when it's run on its own, but when I try to import it and run
it inside a mod_python handler, I get this error:

  File "../common/xml_utils.py", line 80, in parse_item_attribute
  File "/usr/lib/python2.5/xml/dom/minidom.py", line 1924, in
parseString
    from xml.dom import expatbuilder
SystemError: Parent module 'xml.dom' not loaded

Basically, it's the same problem I found in this post:
http://mail.python.org/pipermail/python-list/2007-January/424018.html

This site (http://www.dscpl.com.au/wiki/ModPython/Articles/
ExpatCausingApacheCrash) goes through a detailed explanation, and I
found that the version of pyexpat is newer than libexpat:

# ldd /usr/local/apache2/bin/httpd | grep expat
	libexpat.so.0 => /usr/local/apache2/lib/libexpat.so.0 (0xb7f71000)
# strings /usr/local/apache2/lib/libexpat.so.0 | grep expat_
expat_1.95.2

$ python
Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyexpat
>>> pyexpat.version_info
(2, 0, 0)

But this is where I'm stuck: the article suggests recompiling apache
with the newer version of expat.

Apache's configure utility (I'm using httpd version 2.2.11) doesn't
explicitly describe an expat library option.

Also, if libexpat is version 1.95.2, wouldn't I have to get version
2.0 to be compatible with pyexpat?

If anyone has any advice or suggestions, I'd appreciate hearing them.



More information about the Python-list mailing list