Exception in multiple use of xml.dom.minidom.parse()
Alex Martelli
aleax at aleax.it
Sat Mar 22 04:09:03 EST 2003
Martin Lüthi wrote:
> Dear Pythonistas
>
> An exception is trown when I try to parse a several xml files. For the
> first file everything works out as described in the docs (for Python 2.2),
> using
>
> Python 2.2.2 (#1, Oct 17 2002, 08:48:02)
> [GCC 2.95.3 20010315 (SuSE)] on linux2
>
> python-docs-2.2p1/lib/module-xml.dom.minidom.html
>
>>>> from xml.dom.minidom import parse
>
>>>> dom1 = parse('/my/data1.xml') # parse an XML file by name
>
> When I try to access an other file
>
>>>> dom2 = parse('/my/data2.xml')
>
> I get the following exception
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/dom/minidom.py",
> line 962, in parse
> return _doparse(pulldom.parse, args, kwargs)
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/dom/minidom.py",
> line 953, in _doparse
> events = apply(func, args, kwargs)
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/dom/pulldom.py",
> line 338, in parse
> parser = xml.sax.make_parser()
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/sax/sax2exts.py",
> line 37, in make_parser
> return XMLParserFactory.make_parser(parser_list)
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/sax/saxexts.py",
> line 64, in make_parser
> return self._create_parser(parser_name)
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/sax/saxexts.py",
> line 43, in _create_parser
> return drv_module.create_parser()
> File "/usr/local/lib/python2.2/site-packages/_xmlplus/sax/saxexts.py",
> line 74, in _create_parser
> raise _exceptions.SAXReaderNotAvailable
> TypeError: __init__() takes at least 2 arguments (1 given)
>
> Is this the expected behaviour?
Absolutely not, and indeed that traceback is totally weird -- it
points to a raise of SAXReaderNotAvailable but then it gives you
a TypeError instead...!!!
I suspect you may be running afoul of some installation problem
compounded with / hidden by _xmlplus' import tricks. I am unable
to reproduce your problem with my Python 2.2.2 installation, on
which I seem to have xml 0.5.2 installed in _xmlplus (just reading
the _checkversion.py file in that directory). Perhaps removing
and reinstalling a stable version of _xmlplus might help you...?
Alex
More information about the Python-list
mailing list