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

Image.open with non-image file raises IOError without closing the file #1734

Closed
ZMI-JacobGeiman opened this issue Feb 19, 2016 · 4 comments
Closed

Comments

@ZMI-JacobGeiman
Copy link

Attempting to open a non-image file and catching the IOError causes the file handle to be left open, meaning this file cannot be modified by the process/os until the application stops.

Example code:

from PIL import Image
import os
path = '/path/to/non/image'
try:
    Image.open(path)
except IOError as err:
    print 'This is not an image file'
os.remove(path)

I am running Pillow 3.1.1 on Python 2.7.6
This should be fixable by calling fp.close() before raising the IOError in Image.open

@radarhere
Copy link
Member

Just to confirm, you're running Windows, yes? I ask this because #1651 indicates that this is a Windows issue.

You may also be interested in #1144

@ZMI-JacobGeiman
Copy link
Author

yes, this was on Windows 7.

@radarhere
Copy link
Member

Okay then. Do you mind if this issue is closed as a duplicate then? Between #1651 and #1144, I believe that this is covered.

@ZMI-JacobGeiman
Copy link
Author

please close. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants