From 92dbd59814a3ea0fd9749d2d0260705edd1eb5c8 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 13 May 2015 14:35:17 +0200 Subject: [PATCH] When lxml fails to parse the _service file, instead of showing a backtrace print a userfriendly error which line and column contains the XML syntax error --- osc/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osc/core.py b/osc/core.py index 552127fa..f9561434 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2296,7 +2296,12 @@ rev: %s si = Serviceinfo() if os.path.exists('_service'): if self.filenamelist.count('_service') or self.filenamelist_unvers.count('_service'): - service = ET.parse(os.path.join(self.absdir, '_service')).getroot() + try: + service = ET.parse(os.path.join(self.absdir, '_service')).getroot() + except ET.ParseError as v: + line, column = v.position + print('XML error in _service file on line %s, column %s' % (line, column)) + sys.exit(1) si.read(service) si.getProjectGlobalServices(self.apiurl, self.prjname, self.name) r = si.execute(self.absdir, mode, singleservice, verbose)