Skip to content

Commit 3ff4803

Browse files
author
jhylton
committed
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. git-svn-id: http://svn.python.org/projects/python/trunk@22080 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 8e2a949 commit 3ff4803

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/xml/sax/expatreader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from xml.parsers import expat
1818
except ImportError:
1919
raise SAXReaderNotAvailable("expat not supported",None)
20+
else:
21+
if not hasattr(expat, "ParserCreate"):
22+
raise SAXReaderNotAvailable("expat not supported",None)
2023
from xml.sax import xmlreader, saxutils, handler
2124

2225
AttributesImpl = xmlreader.AttributesImpl

0 commit comments

Comments
 (0)