You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If parsed file does not exist, the untangle message is rather cryptic:
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import untangle
>>> untangle.parse('sfsdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\untangle.py", line 143, in parse
parser.parse(StringIO(filename))
File "C:\Python27\lib\xml\sax\expatreader.py", line 110, in parse
xmlreader.IncrementalParser.parse(self, source)
File "C:\Python27\lib\xml\sax\xmlreader.py", line 125, in parse
self.close()
File "C:\Python27\lib\xml\sax\expatreader.py", line 225, in close
self.feed("", isFinal = 1)
File "C:\Python27\lib\xml\sax\expatreader.py", line 217, in feed
self._err_handler.fatalError(exc)
File "C:\Python27\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: syntax error
The text was updated successfully, but these errors were encountered:
The issue here is that parse tries to be clever and interpret the given string as an XML input string and not a filename. I think the solution here is to have dedicated methods for parsing files and strings.
Having a specific parsefile() method would help, I guess. And the error message could be improved too to something like like - parse() error - invalid argument contents or filename is not found.
Regarding your point about the error message: the problem is that the API for parse() now states that Raises xml.sax.SAXParseException if something goes wrong during parsing. so catching that would break the API :/
If parsed file does not exist, the
untangle
message is rather cryptic:The text was updated successfully, but these errors were encountered: