File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -42,13 +42,18 @@ def _plist_from_popen(popen):
4242 if not out :
4343 return []
4444 try :
45- # Beautiful soup ensures the XML is properly formed after it is parsed
46- # so that it can be used by other less lenient commands without problems
47- xml_representation = BeautifulSoup (out .decode ('utf8' ), 'xml' )
48- if not xml_representation .get_text ():
49- # The output is not in the XML format
45+ try :
46+ # Try simple and fast first if this fails fall back to the slower but better process
5047 return loads (out )
51- return loads (xml_representation .decode ().encode ('utf8' ))
48+ except ExpatError :
49+ # Beautiful soup ensures the XML is properly formed after it is parsed
50+ # so that it can be used by other less lenient commands without problems
51+ xml_representation = BeautifulSoup (out .decode ('utf8' ), 'xml' )
52+
53+ if not xml_representation .get_text ():
54+ # The output is not in the XML format
55+ return loads (out )
56+ return loads (xml_representation .decode ().encode ('utf8' ))
5257 except ExpatError :
5358 return []
5459
You can’t perform that action at this time.
0 commit comments