Skip to content

Unpickle Image serialized with older version of Pillow #8935

@manigoad

Description

@manigoad

What did you do?

Pickle TIff image with pillow==11.1.0 and then de-serialize it with pillow==11.2.1

What did you expect to happen?

I expect the image to be successfully de-serialized

What actually happened?

It's crashing with

What are your OS, Python and Pillow versions?

  • OS:
    Mac OS, Ubuntu
  • Python:
    Python 3.12.7
  • Pillow:
    11.2.1

To reproduce the issue
Install pillow==11.1.0 and execute the following code (you can download the tiff from - https://people.math.sc.edu/Burkardt/data/tif/at3_1m4_01.tif)

from PIL import Image import pickle image = Image.open('./at3_1m4_01.tif') pickle.dump(image, open('./test.pickle', 'wb'))

Then install pillow==11.2.1 and de-serialize the file

 pickle.load(open('./test.pickle', 'rb'))

It's crashing with

File ~/.pyenv/versions/3.12.7/envs/forms/lib/python3.12/site-packages/PIL/ImageFile.py:260, in ImageFile.__setstate__(self, state) 258 def __setstate__(self, state: list[Any]) -> None: 259 self.tile = [] --> 260 self.filename = state[5] 261 super().__setstate__(state) 

I tested with regular PNG file and the issue is not reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions