Commits

Walter Dörwald committed 8dc8d79

Fix handling XML parsing errors. Make sispyphus more robust.

Raise XML parsing errors instead of yielding them.

Don't break when a sisyphus job can't find the script source.

Comments (0)

Files changed (4)

+Changes in 3.11.1 (released 10/18/2010)
+---------------------------------------
+
+*	Fixed two bugs in the error handling for unknown XML parsing events in
+	:meth:`ll.xist.parse.Expat.__call__` and :meth:`ll.xist.parse.SGMLOP.__call__`
+	(exceptions were yielded instead of raised).
+
+*	:mod:`ll.sisyphus` jobs now don't break if they can't find the script source.
+
+
 Changes in 3.11 (released 10/15/2010)
 -------------------------------------
 
 
 args = dict(
 	name="ll-xist",
-	version="3.11",
+	version="3.11.1",
 	description="Extensible HTML/XML generator, cross-platform templating language, Oracle utilities and various other tools",
 	long_description=descr,
 	author="Walter Doerwald",

src/ll/sisyphus.py

 		self.info.filename = self._string(os.path.abspath(filename))
 
 		# Get source code
-		with open(filename.rstrip("c"), "rb") as f:
-			source = f.read()
-			lines = source.splitlines()
-			# find encoding in the first two lines
-			encoding = self.inputencoding
-			if lines and lines[0].startswith(codecs.BOM_UTF8):
-				encoding = "utf-8"
-			else:
-				for line in lines[:2]:
-					match = encodingdeclaration.search(line)
-					if match is not None:
-						encoding = match.group(1)
-			self.source = source.decode(encoding, self.inputerrors)
+		try:
+			with open(filename.rstrip("c"), "rb") as f:
+				source = f.read()
+				lines = source.splitlines()
+				# find encoding in the first two lines
+				encoding = self.inputencoding
+				if lines and lines[0].startswith(codecs.BOM_UTF8):
+					encoding = "utf-8"
+				else:
+					for line in lines[:2]:
+						match = encodingdeclaration.search(line)
+						if match is not None:
+							encoding = match.group(1)
+				self.source = source.decode(encoding, self.inputerrors)
+		except IOError: # Script might have called ``os.chdir()`` before
+			self.source = None
 
 		# Get crontab
 		self.crontab = self._string(os.popen("crontab -l 2>/dev/null").read())

src/ll/xist/parse.py

 				elif evtype == u"url":
 					yield (self.evurl, data)
 				else:
-					yield UnknownEventError(self, (evtype, data))
+					raise UnknownEventError(self, (evtype, data))
 			try:
 				self._parser.Parse(b"", True)
 			except Exception, exc:
 				elif evtype == u"url":
 					yield (self.evurl, data)
 				else:
-					yield UnknownEventError(self, (evtype, data))
+					raise UnknownEventError(self, (evtype, data))
 			self._parser.close()
 			for event in self._flush(True):
 				yield event
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.