]> granicus.if.org Git - python/commitdiff
Ugly fix used when pyexpat is not available.
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 30 Jul 2001 21:49:22 +0000 (21:49 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 30 Jul 2001 21:49:22 +0000 (21:49 +0000)
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.

Lib/xml/sax/expatreader.py

index b8a31ffffa8ce5daf24fe599cf15b5c0c0bc7b5f..7c2bb899c498d4aeb6f5e2e247a5ba76fb9d4331 100644 (file)
@@ -17,6 +17,9 @@ try:
     from xml.parsers import expat
 except ImportError:
     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
 
 AttributesImpl = xmlreader.AttributesImpl