Commits

nneonneo  committed 7232644

hachoir-parser/image/exif: fix warnings from array iteration, fixing issue #28 (reported by hypertex)

  • Participants
  • Parent commits eef5ef7

Comments (0)

Files changed (1)

File hachoir-parser/hachoir_parser/image/exif.py

         for i in xrange(count):
             yield self.EntryClass(self, "entry[]")
         yield UInt32(self, "next", "Offset to next IFD")
-        for i, entry in enumerate(self.array('entry')):
+        for i in xrange(count):
+            entry = self['entry[%d]'%i]
             if 'offset' not in entry:
                 continue
             self.seekByte(entry['offset'].value+self.base_addr//8, relative=False)
         if self["header"].value != "Exif\0\0":
             raise ParserError("Invalid EXIF signature!")
         iff_start = self.absolute_address + self.current_size
+        ifds = []
         for field in TIFF(self):
             yield field
+            if isinstance(field, IFD):
+                ifds.append(field)
 
-        for ifd in self.array('ifd'):
+        for ifd in ifds:
             data = {}
             for i, entry in enumerate(ifd.array('entry')):
                 data[entry['tag'].display] = entry