PIL: write to file-compatible object fails

Bug #718852 reported by Joshua Hopp
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-imaging (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: python-imaging

>>> import io, PIL.Image
>>> img = PIL.Image.new("RGB",(10,10))
>>> stream = io.BytesIO()
>>> img.save(stream,"PPM")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/usr/lib/python2.6/dist-packages/PIL/PpmImagePlugin.py", line 118, in _save
    ImageFile._save(im, fp, [("raw", (0,0)+im.size, 0, (rawmode, 0, 1))])
  File "/usr/lib/python2.6/dist-packages/PIL/ImageFile.py", line 476, in _save
    fh = fp.fileno()
  File "/usr/lib/python2.6/io.py", line 480, in fileno
    self._unsupported("fileno")
  File "/usr/lib/python2.6/io.py", line 333, in _unsupported
    (self.__class__.__name__, name))
io.UnsupportedOperation: BytesIO.fileno() not supported

This is due to line 478 in ImageFile.py, where they rely on an AttributeError to be raised instead of io.UnsupportedOperation.

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

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-imaging (Ubuntu):
status: New → Confirmed
Revision history for this message
Chris Adams (acdha) wrote :

This bug has been fixed in the more actively maintained Pillow fork of PIL:

https://github.com/python-imaging/Pillow/commit/197885164b22f82653af514e66c76f4b778c0b1b

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.