Ugly fix used when pyexpat is not available.

If pyexpat is not available and more than one attempt is made to load
an expat-based xml parser, an empty xml.parser.expat module will be
created.  This empty module will confuse xml.sax.expatreader into
thinking that pyexpat is available.

The ugly fix is to verify that the expat module actually defines the
names that are imported from pyexpat.
This commit is contained in:
Jeremy Hylton 2001-07-30 21:49:22 +00:00
parent 3c19ec4eab
commit e3c37d660f
1 changed files with 3 additions and 0 deletions

View File

@ -17,6 +17,9 @@ try:
from xml.parsers import expat from xml.parsers import expat
except ImportError: except ImportError:
raise SAXReaderNotAvailable("expat not supported",None) raise SAXReaderNotAvailable("expat not supported",None)
else:
if not hasattr(expat, "ParserCreate"):
raise SAXReaderNotAvailable("expat not supported",None)
from xml.sax import xmlreader, saxutils, handler from xml.sax import xmlreader, saxutils, handler
AttributesImpl = xmlreader.AttributesImpl AttributesImpl = xmlreader.AttributesImpl