New submission from Suraj Barkale <suraj+pyt...@barkale.com>: All the error constants in `xml.parsers.expat.errors` are strings. However, when expat raises an ExpatError exception, ExpatError.code attribute is a number. There seems to be no way of associating ExpatError with a corresponding error code from `xml.parsers.expat.errors.
Following code snippet should print "Ignore empty file" but in Python 2.6 it raises ExpatError. from xml.etree import ElementTree from xml.parsers import expat try: ElementTree.parse('') except expat.ExpatError as e: if e.code == expat.errors.XML_ERROR_NO_ELEMENTS: print "Ignore empty file" else: raise ---------- components: XML messages: 82648 nosy: suraj severity: normal status: open title: Expat parser error constants are string descriptions type: behavior versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5355> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com