Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3c37d6

Browse files
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.
1 parent 3c19ec4 commit e3c37d6

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)