PIL fails when trying to parse a streaming png file

Bug #383228 reported by Gord Allott
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-imaging (Ubuntu)
Expired
Medium
Unassigned

Bug Description

Binary package hint: python-imaging

PIL 1.1.6-3ubuntu1 fails when operating on an png file from its parser() method with
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 961, in histogram
    self.load()
  File "/usr/lib/python2.6/dist-packages/PIL/ImageFile.py", line 189, in load
    s = read(self.decodermaxblock)
  File "/usr/lib/python2.6/dist-packages/PIL/PngImagePlugin.py", line 365, in load_read
    return self.fp.read(bytes)
  File "/usr/lib/python2.6/dist-packages/PIL/ImageFile.py", line 300, in read
    data = self.data[pos:pos+bytes]
TypeError: 'NoneType' object is unsubscriptable

this python script will expose the bug:
#!/usr/bin/env python
import PIL.ImageFile
imgfile = open('foo.png')
p = PIL.ImageFile.Parser()

while 1:
    data = imgfile.read(1024)
    if not data:
        break
    p.feed(data)

img = p.close()
img.histogram() # simple operation on PIL.Image object, should work but fails on png files

Attached is a patch that fixes this, a lack of any bug tracker/development contact for python-imaging upstream necessitates it being here. Bug exists on 9.04 definatly

Revision history for this message
Gord Allott (gordallott) wrote :
Revision history for this message
Matt Daubney (daubers) wrote :

Tested on my upto date Jaunty box, and confirmed.

Changed in python-imaging (Ubuntu):
status: New → Confirmed
Changed in python-imaging (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
David Futcher (bobbo) wrote :

I can't reproduce this on Ubuntu Maverick Alpha One (64bit). Is anyone else still having problems with this bug?

Changed in python-imaging (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Greg Bair (gregbair) wrote :

I just tried to reproduce this on Lucid with python-imaging 1.1.7-1. It seems to work ok.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for python-imaging (Ubuntu) because there has been no activity for 60 days.]

Changed in python-imaging (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.