[XML-SIG] SAX exceptions are odd

Jeremy Hylton jeremy@beopen.com
Fri, 6 Oct 2000 11:41:49 -0400 (EDT)

Here is another potential problem with xml exceptions.  There may not
be anything to do about it, because the sax package is, by design,
very clever about imports.

>>> from xml import sax
>>> sax.parse("<a/>", sax.ContentHandler())
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "./../Lib/xml/sax/__init__.py", line 29, in parse
    parser = make_parser()
  File "./../Lib/xml/sax/__init__.py", line 79, in make_parser
    raise SAXException("No parsers found", None)  
xml.sax._exceptions.SAXException: No parsers found

This puzzled me for quite a while, because I was sure I had a parser.

[continuing same session:]
>>> import pyexpat

I start poking around in the internals of the sax implementation.  I
see that I ought to be able to import xml.sax.expatreader.  So I fire
up a new session and try it:

>>> import xml.sax.expatreader
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/jeremy/src/python/dist/src/Lib/xml/sax/expatreader.py", line 10, in ?
    from xml.sax import xmlreader, saxutils, handler
  File "/home/jeremy/src/python/dist/src/Lib/xml/sax/saxutils.py", line 6, in ?
    import os, urlparse, urllib, types
  File "/home/jeremy/src/python/dist/src/Lib/urllib.py", line 26, in ?
    import socket
  File "/home/jeremy/src/python/dist/src/Lib/socket.py", line 41, in ?
    from _socket import *
ImportError: libssl.so.0: cannot open shared object file: No such file or directory

So the problem is a bogus local configuration for shared libraries.
On the one hand, I haven't installed Python properly, so I shouldn't
expect things to work.  On the other hand, it would be helpful if
unexpected exceptions could be reported.  Is there any way to provide
an informative error message in this case?