Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebPImagePlugin.py - ResourceWarning: unclosed file #3340

Closed
pajadam opened this issue Sep 7, 2018 · 3 comments
Closed

WebPImagePlugin.py - ResourceWarning: unclosed file #3340

pajadam opened this issue Sep 7, 2018 · 3 comments
Labels
Bug Any unexpected behavior, until confirmed feature.
Milestone

Comments

@pajadam
Copy link

pajadam commented Sep 7, 2018

What did you do?

> python -Wd
Python 3.7.0 (default, Jul 15 2018, 10:44:58)
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> with Image.open('tshirt.webp') as img:
...     img.save('tshirt.png', 'PNG')
...
/home/pajadam/.venv/hype/lib/python3.7/site-packages/PIL/WebPImagePlugin.py:156: ResourceWarning: unclosed file <_io.BufferedReader name='tshirt.webp'>
  self.fp = BytesIO(data)
>>>

What did you expect to happen?

No warnings, especially while using context manager.

What actually happened?

Following warning occurs:

/home/pajadam/.venv/hype/lib/python3.7/site-packages/PIL/WebPImagePlugin.py:156: ResourceWarning: unclosed file <_io.BufferedReader name='tshirt.webp'>
  self.fp = BytesIO(data)

What versions of Pillow and Python are you using?

  • Pillow==5.2
  • Python 3.7

Minimal example:

from PIL import Image

with Image.open('tshirt.webp') as img:
     img.save('tshirt.png', 'PNG')
@radarhere radarhere changed the title WebPImagePlugin.py - ResourceWarning: unclosed file. WebPImagePlugin.py - ResourceWarning: unclosed file Sep 8, 2018
@hugovk hugovk added the Bug Any unexpected behavior, until confirmed feature. label Sep 8, 2018
@radarhere
Copy link
Member

Thanks for reporting this. This can be replicated using transparent.webp from the Pillow test images.

I have created PR #3341

@hugovk
Copy link
Member

hugovk commented Oct 18, 2018

Re-opening as #3341 caused an error and was reverted in #3415.

@radarhere
Copy link
Member

I have created PR #3418 as a revised solution to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

No branches or pull requests

3 participants