Skip to content

Change in behavior with JPEG Images in 11.2.0 #8857

@davidmezzetti

Description

@davidmezzetti

It looks like something in Pillow 11.2 introduced an issue similar to this: #8472. This time with the filename attribute.

What did you do?

import pickle

from io import BytesIO

from PIL import Image

im = Image.open("anyimage.jpg")

p = pickle.dumps(im)
im = pickle.loads(p)

# Fails in 11.2, works in 11.1
output = BytesIO()
im.save(output, format=im.format, quality="keep")

What did you expect to happen?

The code above to work.

What actually happened?

Traceback (most recent call last):
  File "test.py", line 14, in <module>
    im.save(output, format=im.format, quality="keep")
  File "/local/lib64/python3.9/site-packages/PIL/Image.py", line 2546, in save
    if isinstance(self, ImageFile.ImageFile) and filename == self.filename:
  File "/local/lib64/python3.9/site-packages/PIL/JpegImagePlugin.py", line 400, in __getattr__
    raise AttributeError(name)
AttributeError: filename

What are your OS, Python and Pillow versions?

  • OS: Linux
  • Python: Python 3.9
  • Pillow: 11.2

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