Fix #2311 (Failure to parse an lrf file)

This commit is contained in:
Kovid Goyal 2009-04-26 15:35:24 -07:00
parent 8e68f9d4dd
commit 021149097f
2 changed files with 22 additions and 17 deletions

View File

@ -970,7 +970,12 @@ class Canvas(LRFStream):
stream = cStringIO.StringIO(self.stream)
while stream.tell() < len(self.stream):
tag = Tag(stream)
self._contents.append(PutObj(self._document.objects, *struct.unpack("<HHI", tag.contents)))
try:
self._contents.append(
PutObj(self._document.objects,
*struct.unpack("<HHI", tag.contents)))
except struct.error:
print 'Canvas object has errors, skipping.'
def __unicode__(self):
s = '\n<%s objid="%s" '%(self.__class__.__name__, self.id,)