[GRASS-SVN] r65662 - grass/branches/releasebranch_7_0/lib/python/script
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 19 12:20:57 PDT 2015
Author: wenzeslaus
Date: 2015-07-19 12:20:57 -0700 (Sun, 19 Jul 2015)
New Revision: 65662
Modified:
grass/branches/releasebranch_7_0/lib/python/script/task.py
Log:
backport r65200 (more error for script.task.parse_interface)
Modified: grass/branches/releasebranch_7_0/lib/python/script/task.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/script/task.py 2015-07-19 19:20:40 UTC (rev 65661)
+++ grass/branches/releasebranch_7_0/lib/python/script/task.py 2015-07-19 19:20:57 UTC (rev 65662)
@@ -24,6 +24,13 @@
import xml.etree.ElementTree as etree
except ImportError:
import elementtree.ElementTree as etree # Python <= 2.4
+from xml.parsers import expat # TODO: works for any Python?
+# Get the XML parsing exceptions to catch. The behavior chnaged with Python 2.7
+# and ElementTree 1.3.
+if hasattr(etree, 'ParseError'):
+ ETREE_EXCEPTIONS = (etree.ParseError, expat.ExpatError)
+else:
+ ETREE_EXCEPTIONS = (expat.ExpatError)
from utils import decode
from core import *
@@ -506,7 +513,11 @@
:param parser:
:param blackList:
"""
- tree = etree.fromstring(get_interface_description(name))
+ try:
+ tree = etree.fromstring(get_interface_description(name))
+ except ETREE_EXCEPTIONS as error:
+ raise ScriptError(_("Cannot parse interface description of"
+ "<{name}> module: {error}").format(name=name, error=error))
return parser(tree, blackList=blackList).get_task()
More information about the grass-commit
mailing list