I'm not sure if it's been noted before, but there's an incompatility in PIL with the FlashPix file IO and python 2.4 and up. Trying to load such a file can give OverflowError; see patch below.<br><br><br><br>In the file
OleFileIO.py, the function i32() uses <<. Several parts of this file then rely on <br>the old behavior of this function to wrap round to negative values once the <br>input is past 0xFFFFFFFF (ie 1<<32 == 0)<br>
<br>Python 2.4 and up no longer does this, which means that the library fails to spot the <br>end of header bytes, as it tests for == -1 and ==-2 (e.g. in loadfat()).<br> <br>This can result in an OverflowError being thrown, which is a problem for me when someone inputs an invalid file (I'm actually seeing this on MS word files posted to a website as
<br>images by mistake, but it could happen with a valid fpx file).<br><br>A simple way to get back to the previous correct behavior would be to patch as follows:<br><br>diff OleFileIO.py.new OleFileIO.py<br>46c46,49<br>< def i32(c, o = 0):
<br>< return ord(c[o])+(ord(c[o+1])<<8)+(ord(c[o+2])<<16)+(ord(c[o+3])<<24)<br>---<br>> def i32(c, o = 0):<br>> ival = ord(c[o])+(ord(c[o+1])<<8)+(ord(c[o+2])<<16)+(ord(c[o+3])<<24)
<br>> if ival > 0x80000000:<br>> ival -= 0x100000000<br>> return ival<br><br>but a good alternative would be to fix all the tests in the library.<br><br>I guess this part of the library doesn't get exercised much :)
<br><br>BR,<br><br>Robert Bunting.<br>exoweb.<br><br><br> <br>