Catching exception information from ExpatError
mesteve_b at hotmail.com
Thu Feb 26 14:03:00 CET 2004
I'm opening an xml file with minidom.
When I have a mismatch in the XML file, I simply want my python script to
not only stop gracefully, but also to call up UltraEdit with that xml file,
and highlighting the offending line (keep in mind UEdit can take command
line argument with the row and column)
When I let the exception be caught by default, I notice that I get:
xml.parsers.expat.ExpatError: mismatched tag: line 19, column 7
But when I catch the error with: except exp.ExpatError:
and then get the information from sys.exc_info(), it returns a tuple that
class xml.parsers.expat.ExpatError at 0x00F7FF90>,
<xml.parsers.expat.ExpatError instance at 0x00FFD800>, <traceback object at
I want to somehow get the more useful: "line 19, column 7" and parse that
and call ultraedit with the 19 and the 7.
Can you suggest something, is it obvious?
More information about the Python-list