[Image-SIG] Image.putdata, Python crash

Rune Strand rune.strand at gmail.com
Thu Jun 15 23:33:16 CEST 2006


Hi,

Because of my lousy code/PIL newbieness or something completely 
different, Windows Python 2.4.3 crashes (in _imaging.pyd) after a call 
to  Image.putdata(a_list_of_ints).
Python gives no errors messages.

The image, a BMP file is written by PIL itself. I have thousands of 
them. I've tested several of them of them with same result.
Saving a copy of the file from Paint.exe etc. does not change anything.

The files are created by saving only the R band after Image.split(). 
They contain only two colours, 0 and 255.

The file(s) _does not_ verify. Image.verify() gives AttributeError, but 
Image.load() and .show() and all other methods works.

Simplyfied repro code below. UUE of the insulting BMP file included 
below. I'll happily send a copy of the BMP.

Rune

---------------- Script
import Image

bmp_file = '9_86955_(1).bmp'
img = Image.open(bmp_file)
#img.verify()  # gives AttributeError, see traceback below
#img.load() # no errors, and does not affect crashing

# 476 int elements, 0s and 255s
img_data = list(img.getdata())

# process data (ie. change some 0's to 255)
#img_data = process(img_data)

# crashes Python (module _imaging.pyd)
img.putdata(img_data)

# # .verify() traceback
"""
Traceback (most recent call last):
  File "K:\ocr\chars\fix\bug_repro.py", line 14, in ?
    img_data = list(img.getdata())
  File "C:\dev\Python\Lib\site-packages\PIL\Image.py", line 796, in getdata
    self.load()
  File "C:\dev\Python\Lib\site-packages\PIL\ImageFile.py", line 161, in load
    read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'
"""
----------------



----------- UUE
begin 666 9_86955_(1).bmp
M0DUF!@       #8$   H    $0   !P    !  @      # "   !     0 
M   !     0        $! 0$" @(" P,# P0$! 0%!04%!@8&!@<'!P<(" @(
M"0D)"0H*"@H+"PL+# P,# T-#0T.#@X.#P\/#Q 0$! 1$1$1$A(2$A,3$Q,4
M%!04%145%186%A87%Q<7&!@8&!D9&1D:&AH:&QL;&QP<'!P='1T='AX>'A\?
M'Q\@(" @(2$A(2(B(B(C(R,C)"0D)"4E)24F)B8F)R<G)R at H*"@I*2DI*BHJ
M*BLK*RLL+"PL+2TM+2XN+BXO+R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KZ^OL[.SL[>WM[>[N[N[O[^_O\/#P\/'Q\?'R\O+R\_/S\_3T]/3U
M]?7U]O;V]O?W]_?X^/CX^?GY^?KZ^OK[^_O[_/S\_/W]_?W^_O[^_____P 
M     /\ _____P          _________________P        #_________
M__________\      /_______P#___________\     ________________
M______\   #______________________P   /________\   #_________
M    ________     /________\   #______P      _________P     
M          #___\  /__                _____P#___\         ____
M_____________P      ____________________     /______________
M______\   #______________________P   /______________________
M     /_______P   /________\   #_________    _________P   /__
M_____P    #_________    _________P   /________\   #_________
M    _________P   /________\   #__P  ____    ________________
M_P#___\   #_____________________      #_____ /____\ _____P 
M        _P#_  #_  #___\                                    
2                       
 
end


More information about the Image-SIG mailing list